473,761 Members | 8,933 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why keep identity-based equality comparison?

Hello,

Guido has decided, in python-dev, that in Py3K the id-based order
comparisons will be dropped. This means that, for example, "{} < []"
will raise a TypeError instead of the current behaviour, which is
returning a value which is, really, id({}) < id([]).

He also said that default equality comparison will continue to be
identity-based. This means that x == y will never raise an exception,
as is the situation is now. Here's his reason:
Let me construct a hypothetical example: suppose we represent a car
and its parts as objects. Let's say each wheel is an object. Each
wheel is unique and we don't have equivalency classes for them.
However, it would be useful to construct sets of wheels (e.g. the set
of wheels currently on my car that have never had a flat tire). Python
sets use hashing just like dicts. The original hash() and __eq__
implementation would work exactly right for this purpose, and it seems
silly to have to add it to every object type that could possibly be
used as a set member (especially since this means that if a third
party library creates objects for you that don't implement __hash__
you'd have a hard time of adding it).


Now, I don't think it should be so. My reason is basically "explicit is
better than implicit" - I think that the == operator should be reserved
for value-based comparison, and raise an exception if the two objects
can't be meaningfully compared by value. If you want to check if two
objects are the same, you can always do "x is y". If you want to create
a set of objects based on their identity (that is, two different
objects with the same value are considered different elements), you
have two options:
1. Create another set type, which is identity-based - it doesn't care
about the hash value of objects, it just collects references to
objects. Instead of using set(), you would be able to use, say,
idset(), and everything would work as wanted.
2. Write a class like this:

class Ref(object):
def __init__(self, obj):
self._obj = obj
def __call__(self):
return self._obj
def __eq__(self, other):
return isinstance(othe r, Ref) and self._obj is other._obj
def __hash__(self):
return id(self._obj) ^ 0xBEEF

and use it like this:

st = set()
st.add(Ref(whee l1))
st.add(Ref(whee l2))
if Ref(wheel1) in st:
....
Those solutions allow the one who writes the class to define a
value-based comparison operator, and allow the user of the class to
explicitly state if he wants value-based behaviour or identity-based
behaviour.

A few more examples of why this explicit behaviour is good:

* Things like "Decimal(3. 0) == 3.0" will make more sense (raise an
exception which explains that decimals should not be compared to
floats, instead of returning False).
* You won't be able to use objects as keys, expecting them to be
compared by value, and causing a bug when they don't. I recently wrote
a sort-of OCR program, which contains a mapping from a numarray array
of bits to a character (the array is the pixel-image of the char).
Everything seemed to work, but the program didn't recognize any
characters. I discovered that the reason was that arrays are hashed
according to their identity, which is a thing I had to guess. If
default == operator were not defined, I would simply get a TypeError
immediately.
* It is more forward compatible - when it is discovered that two types
can sensibly be compared, the comparison can be defined, without
changing an existing behaviour which doesn't raise an exception.

My question is, what reasons are left for leaving the current default
equality operator for Py3K, not counting backwards-compatibility?
(assume that you have idset and iddict, so explicitness' cost is only
two characters, in Guido's example)

Thanks,
Noam

Jan 9 '06
37 2816
Antoon Pardon <ap*****@forel. vub.ac.be> writes:
Op 2006-01-11, Mike Meyer schreef <mw*@mired.org> :
Antoon Pardon <ap*****@forel. vub.ac.be> writes:
Op 2006-01-11, Mike Meyer schreef <mw*@mired.org> :
Antoon Pardon <ap*****@forel. vub.ac.be> writes:
> Op 2006-01-10, Mike Meyer schreef <mw*@mired.org> :
>>> Now you can take the practical option and decide that programmaticall y
>>> it make no sense to compare a specific couple of values and throw an
>>> exception in this case, but it doesn't matter much which test you are
>>> conducting at that point.
>> Can you provide a case where having a test for equality throw an
>> exception is actually useful?
> I'm not going to bother with that.
Since you're being vague about what you want,
I would like some consistency. Either all comparisons between objects
of different types throw an exception by default or none does. That's a very silly thing to ask for. It presumes that all types are
the same. They aren't.

It doesn't presume anything like that.


Yes it does. It presumes that all operators of all types either always
make sense, or there are always situations where they don't
It also presumes that all comparisons are the same. They aren't.

It doesn't presume that either.


Yes it does. It presumes that all operators either always make sesne,
or there are always situations where they don't.
To use an overworked analogy, you might as well ask
that you either have to peel all fruit, or that you never have to peel
a fruit.

Bad analogy since a fruit is not a relationship.


I suggest you look up the meaning of the word "analogy".
In any case, the proposeed behavior *is* consistent. The behavior for
all builtin types will be that comparisons that don't make sense will
throw exceptions.

It is only consistent if you start from an inconsistent view and then
check for how consistently this view is followed. There is nothing
consistent in telling that 1 == (1,3) makes sense and 1 < (1,3)
doesn't make sense. Set theoretically both 1 and (1,3) are sets.


Of course there are types for which the given behaviors don't make
sense. However, we're not talking about user-defined relations on
user-defined types with syntax that isn't supported by the
language. We're talking about the builtin relationships defined on the
builtin types.
There is a use case for things like 1 < (1,3) making sense and denoting
a total order. When you have a hetergenous list, having a total order
makes it possible to sort the list which will make it easier to
weed out duplicates. So why don't you demand a use case for the
new behaviour to counter this use case?
Yes, there is. And you are perfectly free to implement a type that
behaves that way if you want to. I don't need a use case to "counter"
this one; I just need to show that this use case can be reasonably
covered by the proposed mechanism.
IMO it would be better if it was possible to associate some kind
of order function with the container. Because the order most usefull
for comparing between two instances doesn't need to be the most usefull
order in finding an element from a container.
No, it wouldn't. Order relationships are a property of the type, not
the container. The order relationships are right where they belong -
attached to the type. That notwithstanding , it's often practical to be
able to override the order function for some specific method (and
would be even if the order function were associated with the container
instead of the type), so some of the methods that use order allow you
to provide a function to use for them. If you really want a container
type that has an order function associated with it, you can write
one. If you want it made part of the language, you'll have to provide
a use case.
I could impose a total order on sets, so that I can use a bisection
algorithm on a container of them, but such an order is in general
less usefull than the superset ordering when you are manipulating
sets.


And you're free to implement a subclass of sets that does that. If you
want to argue that the builtin sets should do that, you can - but
that's unrelated to the question of how the comparison operators
behave for the rest of the bulitin types. At least, it doesn't matter
unless you try and force all the types and operators to be the same.
Since we're talking about Py3K here, there is no
"default" behavior. User-defined classes all inherit from builtin
types, and will get the behavior of their comparison operators from
those types. In particular, those that inherit from object will get
objects behavior, which means they'll get equality as identity.

But if this makes any behaviour defined on objects consistent by
definition, because the only criteria you seem to have for consistency
is the inherited behaviour from object. If object would use a
random function to decide that would be consistent too, because it
would be the behaviour inherited by other classes. I don't find this
a usefull way to measure consistency.


But you can use a random function to decide no matter *how* the
bulitin relationships behave. That's part of the powero of Python - it
doesn't impose arbitrary constraints on what you can do. You seem to
think we should either disallow comparison operators from throwing
exceptions, or force them to throw exceptions under some unstated
conditions. But not all types are the same; some may not *have*
conditions under which all relational operators need to throw an
exception. And not all comparisons are the same; some may not *have*
conditions under which they need to throw an exception.
and won't provide
examples to show why you want things to behave whatever way you want,
I can't really say much else about it.
Did you see examples that show why Guido wants things to behave whatever
Guido's idea is a change from current behaviour. Each time I saw some
argue a change here, people seem to expect a use case from that person.
So why ask a use case of me and just accepy Guido's idea.

For one thing, Guido has a long history of doing excellent Python
design work. For another, this issue was thrashout out at length in
comp.lang.pytho n some years ago. What Guido proposed is inline with
the conclusions of those discussions.

Then it should be easy to come up with the use cases and arguments pro
this idea presented then. If this idea of Guido was the result of his
briliance in language design, surely there should be arguments and
use cases to confirm that.


It's no easier for me to find them than for you to find them. And I'm
not guido - if you want his thoughts, you'll have to ask him.

<mike
--
Mike Meyer <mw*@mired.or g> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jan 12 '06 #31
Op 2006-01-12, Mike Meyer schreef <mw*@mired.org> :
Antoon Pardon <ap*****@forel. vub.ac.be> writes:
Op 2006-01-11, Mike Meyer schreef <mw*@mired.org> :
[ BIG CUT ]

I'm going to drop this part. I disagree with you and think
I can show some of your argument invalid. Hoever I also doubt
something fruitfull can come from continuing this. Lets agree
to disagree.
IMO it would be better if it was possible to associate some kind
of order function with the container. Because the order most usefull
for comparing between two instances doesn't need to be the most usefull
order in finding an element from a container.
No, it wouldn't. Order relationships are a property of the type, not
the container. The order relationships are right where they belong -
attached to the type.


Order relationships are only a property of the type in a particular
sense. There certainly is not a one on one relationship between
order relationships and types. A type can have multiple order relationships
all usefull in different circumstances. If a specific order is
only usefull in the context of a spefic container I see no problem
with associating the order with the container.
That notwithstanding , it's often practical to be
able to override the order function for some specific method (and
would be even if the order function were associated with the container
instead of the type), so some of the methods that use order allow you
to provide a function to use for them. If you really want a container
type that has an order function associated with it, you can write
one. If you want it made part of the language, you'll have to provide
a use case.
Fair enough. Take the heapqueue module. The times that I had need
for a heapqueue this module was useless to me. The reason always
boiled down to the fact that the order defined on the object
(as far as there was one) was not the order in which I wanted
the objects processed. e.g. I want a heapqueue of sets that gives
priority according to the number of elements in the set. Or I have
two heapqueues each of intervals. The first gives priority according
to the low value, the second gives priority according the the high
value.
algorithm on a container of them, but such an order is in general
less usefull than the superset ordering when you are manipulating
sets.


And you're free to implement a subclass of sets that does that.


But that is not usefull to me. Take sets. It's been a while so
I'm not sure I can dig it back up, but I once had an algorithm
manipulating sets, where this manipulation would involve the
normal superset order. This algorithm had two charateristics.

1) Manipulating certain sets, made the manipulation of other
sets unnecessary.

2) Manipulating smaller sets was faster than manipulating
larger sets.

3) Sets were constantly added and removed from the manipulating
pool.

These characteristics made this a natuaral candidate for a heapqueue
that used the number of elements as (inverse) priority.

However the manipulation of a single set needed the normal
superset relationship as order relation.

So making a subclass of sets with an order usefull for the
heapqueue would only be a marginal improvement to the
existing situation.
If you
want to argue that the builtin sets should do that, you can - but
that's unrelated to the question of how the comparison operators
behave for the rest of the bulitin types.


What I argue is that there is no single order for a specific type.
There can be an order that is most usefull in general but which order
is usefull at a specific point depends on the context. Sometimes
this context is the container that the types belongs to, like
a heapqueue. Associating that order with the container seems to
most natural to treat this kind of circumstances.

--
Antoon Pardon
Jan 13 '06 #32
Antoon Pardon <ap*****@forel. vub.ac.be> writes:
If you
want to argue that the builtin sets should do that, you can - but
that's unrelated to the question of how the comparison operators
behave for the rest of the bulitin types. What I argue is that there is no single order for a specific type.


I think that depends on your definition of type, but let it go.
There can be an order that is most usefull in general but which order
is usefull at a specific point depends on the context.


Yes. So what? Does this fact suggest some change to Python that would
improve it? If so, you need to mention it. If not, why bring it up at
all?

<mike
--
Mike Meyer <mw*@mired.or g> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jan 14 '06 #33
Mike Meyer wrote:
sp*******@gmail .com writes:
try:
return a == b
except TypeError:
return a is b

This isn't "easy". It's an ugly hack you have to use everytime you
want to iterate through a heterogenous set doing equality tests.


I wouldn't define this as an "ugly hack". These are four simple line,
which state clearly and precisely what you mean, and always work. I have
seen ugly hacks in my life, and they don't look like this.
You're replacing "false" with an "emphatheti c false", that *all*
containers to change for the worse to deal with it.
I don't see how they change for the worse if they have exactly the same
functionality and a few added lines of implementation.
Also, Mike said that you'll need an idlist object too - and I think
he's right and that there's nothing wrong with it.

Except that we now need four versions of internal data structures,
instead of two: list, tuple, idlist, idtuple; set, idset, frozenset,
frozenidset, and so on. What's wrong with this is that it's ugly.


Again, "ugly" is a personal definition. I may call this "explicitne ss".
By the way, what's the "and so on" - I think that these are the only
built-in containers.
Note that while you
can easily define the current == behaviour using the proposed
behaviour, you can't define the proposed behaviour using the current
behaviour.

Yes you can, and it's even easy. All you have to do is use custom
classes that raise an exception if they don't


You can't create a general container with my proposed == behaviour.
That's what I meant.
Also note that using the current behaviour, you can't easily
treat objects that do define a meaningful value comparison, by
identity.

Yes you can. Just use the "is" operator.


Sorry, I wasn't clear enough. In "treating" I meant how containers treat
the objects they contain. For example, you can't easily map a value to a
specific instance of a list - dict only lets you map a value to a
specific *value* of a list. Another example - you can't search for a
specific list object in another list.
Note that this behavior also has the *highly* pecular behavior that a
doesn't necessarily equal a by default.
Again, "peculiar" is your aesthethic sense. I would like to hear
objections based on use cases that are objectively made more difficult.
Anyway, I don't see why someone should even try checking if "a==a", and
if someone does, the exception can say "this type doesn't support value
comparison. Use the "is" operator".
I will point out why your example usages aren't really usefull if
you'll repeat your post with newlines.

Here they are:

* Things like "Decimal(3. 0) == 3.0" will make more sense (raise an
exception which explains that decimals should not be compared to
floats, instead of returning False).
* You won't be able to use objects as keys, expecting them to be
compared by value, and causing a bug when they don't. I recently wrote
a sort-of OCR program, which contains a mapping from a numarray array
of bits to a character (the array is the pixel-image of the char).
Everything seemed to work, but the program didn't recognize any
characters. I discovered that the reason was that arrays are hashed
according to their identity, which is a thing I had to guess. If
default == operator were not defined, I would simply get a TypeError
immediately.
* It is more forward compatible - when it is discovered that two types
can sensibly be compared, the comparison can be defined, without
changing an existing behaviour which doesn't raise an exception.

The third example applies to the Decimal==float use case, and for every
type that currently has the default identity-based comparison and that
may benefit from a value-based comparison. Take the class

class Circle(object):
def __init__(self, center, radius):
self.center = center
self.radius = radius

Currently, it's equal only to itself. You may decide to define an
equality operator which checks whether both the center and the radius
are the same, but since you already have a default equality operator,
that change would break backwards-compatibility.

Noam
Jan 14 '06 #34
Noam Raphael <sp*******@gmai l.com> writes:
Also note that using the current behaviour, you can't easily
treat objects that do define a meaningful value comparison, by
identity. Yes you can. Just use the "is" operator.

Sorry, I wasn't clear enough. In "treating" I meant how containers
treat the objects they contain. For example, you can't easily map a
value to a specific instance of a list - dict only lets you map a
value to a specific *value* of a list.


Wrong. All you have to do is create a list type that uses identity
instead of value for equality testing. This is easier than mapping an
exception to false.
Another example - you can't
search for a specific list object in another list.
Your proposed == behavior doesn't change that at all.
I will point out why your example usages aren't really usefull if
you'll repeat your post with newlines.

Here they are:
* Things like "Decimal(3. 0) == 3.0" will make more sense (raise an
exception which explains that decimals should not be compared to
floats, instead of returning False).


While I agree that Decimal(3.0) == 3.0 returning false doesn't make
sense, having it raise an exception doesn't make any more sense. This
should be fixed, but changing == doesn't fix it.
* You won't be able to use objects as keys, expecting them to be
compared by value, and causing a bug when they don't. I recently wrote
a sort-of OCR program, which contains a mapping from a numarray array
of bits to a character (the array is the pixel-image of the char).
Everything seemed to work, but the program didn't recognize any
characters. I discovered that the reason was that arrays are hashed
according to their identity, which is a thing I had to guess. If
default == operator were not defined, I would simply get a TypeError
immediately.
This isn't a use case. You don't get correct code with either version
of '=='. While there is some merit to doing things that make errors
easier to find, Python in general rejects the idea of adding
boilerplate to do so. Your proposal would generate lots of boilerplate
for many practical situations.
* It is more forward compatible - when it is discovered that two types
can sensibly be compared, the comparison can be defined, without
changing an existing behaviour which doesn't raise an exception.


Sorry, but that doesn't fly. If you have code that relies on the
exception being raised when two types are compared, changing it to
suddenly return a boolean will break that code.

<mike
--
Mike Meyer <mw*@mired.or g> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jan 14 '06 #35
Mike Meyer wrote:
Noam Raphael <sp*******@gmai l.com> writes:
Also note that using the current behaviour, you can't easily
treat objects that do define a meaningful value comparison, by
identity.

Yes you can. Just use the "is" operator.
Sorry, I wasn't clear enough. In "treating" I meant how containers
treat the objects they contain. For example, you can't easily map a
value to a specific instance of a list - dict only lets you map a
value to a specific *value* of a list.

Wrong. All you have to do is create a list type that uses identity
instead of value for equality testing. This is easier than mapping an
exception to false.

You're suggesting a workaround, which requires me to subclass everything
that I want to lookup by identity (and don't think it's simple - I will
have to wrap a lot of methods that return a list to return a list with a
modified == operator).

I'm suggesting the use of another container class: iddict instead of
dict. That's all.
I don't think that mapping an exception to false is so hard (certainly
simpler than subclassing a list in that way), and the average user won't
have to do it, anyway - it's the list implementation that will do it.
Another example - you can't
search for a specific list object in another list.

Your proposed == behavior doesn't change that at all.


It does - *use idlist*.
I will point out why your example usages aren't really usefull if
you'll repeat your post with newlines.
Here they are:
* Things like "Decimal(3. 0) == 3.0" will make more sense (raise an
exception which explains that decimals should not be compared to
floats, instead of returning False).

While I agree that Decimal(3.0) == 3.0 returning false doesn't make
sense, having it raise an exception doesn't make any more sense. This
should be fixed, but changing == doesn't fix it.

No, it can't be fixed your way. It was decided on purpose that Decimal
shouldn't be comparable to float, to prevent precision errors. I'm
saying that raising an exception will make it clearer.
* You won't be able to use objects as keys, expecting them to be
compared by value, and causing a bug when they don't. I recently wrote
a sort-of OCR program, which contains a mapping from a numarray array
of bits to a character (the array is the pixel-image of the char).
Everything seemed to work, but the program didn't recognize any
characters. I discovered that the reason was that arrays are hashed
according to their identity, which is a thing I had to guess. If
default == operator were not defined, I would simply get a TypeError
immediately .

This isn't a use case. You don't get correct code with either version
of '=='. While there is some merit to doing things that make errors
easier to find, Python in general rejects the idea of adding
boilerplate to do so. Your proposal would generate lots of boilerplate
for many practical situations.

I would say that there's a lot of merit to doing things that make errors
easier to find. That's what exceptions are for.

Please say what those practical situations are - that what I want.
(I understand. You think that added containers and a try...except fro
time to time aren't worth it. I think they are. Do you have any other
practical situations?)
* It is more forward compatible - when it is discovered that two types
can sensibly be compared, the comparison can be defined, without
changing an existing behaviour which doesn't raise an exception.

Sorry, but that doesn't fly. If you have code that relies on the
exception being raised when two types are compared, changing it to
suddenly return a boolean will break that code.

You are right, but that's the case for every added language feature (if
you add a method, you break code that relies on an AttributeError. ..)
You are right that I'm suggesting a try...except when testing if a list
contains an object, but a case when you have a list with floats and
Decimals, and you rely on "Decimal("3 .0") in list1" to find only
Decimals seems to me a little bit far-fetched. If you have another
example, please say it.

Noam
Jan 15 '06 #36
Noam Raphael <sp*******@gmai l.com> writes:
Mike Meyer wrote:
Noam Raphael <sp*******@gmai l.com> writes:
>Also note that using the current behaviour, you can't easily
>treat objects that do define a meaningful value comparison, by
>identity .
Yes you can. Just use the "is" operator.
Sorry, I wasn't clear enough. In "treating" I meant how containers
treat the objects they contain. For example, you can't easily map a
value to a specific instance of a list - dict only lets you map a
value to a specific *value* of a list. Wrong. All you have to do is create a list type that uses identity
instead of value for equality testing. This is easier than mapping an
exception to false.

You're suggesting a workaround, which requires me to subclass
everything that I want to lookup by identity (and don't think it's
simple - I will have to wrap a lot of methods that return a list to
return a list with a modified == operator).


No, I'm suggesting a general solution that works for *every* case
where you want something other than the standard equality case.
I'm suggesting the use of another container class: iddict instead of
dict. That's all.
You're suggesting adding a new builtin type to the language that deals
with one special case. Is this special case really that common? I
don't recall seeing anyone else ask for it in the last 10 years or so.
I don't think that mapping an exception to false is so hard (certainly
simpler than subclassing a list in that way), and the average user
won't have to do it, anyway - it's the list implementation that will
do it.
I disagree with both your assessments. Subclassing is trivial. And
every user who wants to compare elements in a container that might
include heterogenous types has to deal with this issue. That's more
than just lists, even if you only pay atttention to builtin
types. Nuts - you have to deal with it when you're adding elements to
a dictionary.
Another example - you can't
search for a specific list object in another list.

Your proposed == behavior doesn't change that at all.

It does - *use idlist*.


You're mixing two proposals into the same thread. You'll forgive me
for referring to the original proposal.
I will point out why your example usages aren't really usefull if
you'll repeat your post with newlines.

Here they are:
* Things like "Decimal(3. 0) == 3.0" will make more sense (raise an
exception which explains that decimals should not be compared to
floats, instead of returning False).

While I agree that Decimal(3.0) == 3.0 returning false doesn't make
sense, having it raise an exception doesn't make any more sense. This
should be fixed, but changing == doesn't fix it.

No, it can't be fixed your way. It was decided on purpose that Decimal
shouldn't be comparable to float, to prevent precision errors. I'm
saying that raising an exception will make it clearer.


So how come I can compare decimals to floats?
type(d) <class 'decimal.Decima l'> d < 2.0 True d > 0.0 False

Are you proposing we should break this, which currently functions
correctly?

You're correct that this can't be fixed by "fixing" decimal alone. It
requires more work than that. It may not be possible to fix this
properly before Py3K. But your proposal can't be done until then
anyway. I've already started the process of proposing a proper fix.
* You won't be able to use objects as keys, expecting them to be
compared by value, and causing a bug when they don't. I recently wrote
a sort-of OCR program, which contains a mapping from a numarray array
of bits to a character (the array is the pixel-image of the char).
Everything seemed to work, but the program didn't recognize any
characters . I discovered that the reason was that arrays are hashed
according to their identity, which is a thing I had to guess. If
default == operator were not defined, I would simply get a TypeError
immediatel y.

This isn't a use case. You don't get correct code with either version
of '=='. While there is some merit to doing things that make errors
easier to find, Python in general rejects the idea of adding
boilerplate to do so. Your proposal would generate lots of boilerplate
for many practical situations.

I would say that there's a lot of merit to doing things that make
errors easier to find. That's what exceptions are for.


Exceptions are for finding *programming errors*? That's a rather
unusual view of exceptions.
Please say what those practical situations are - that what I want.
(I understand. You think that added containers and a try...except fro
time to time aren't worth it. I think they are. Do you have any other
practical situations?)
That try...except is the boilerplate I'm talking about.
You are right that I'm suggesting a try...except when testing if a
list contains an object, but a case when you have a list with floats
and Decimals, and you rely on "Decimal("3 .0") in list1" to find only
Decimals seems to me a little bit far-fetched. If you have another
example, please say it.


But you're suggesting changing *far more* than just decimals, and have
made multiple suggestions. Exactly what are you looking for an example
of?

<mike
--
Mike Meyer <mw*@mired.or g> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jan 15 '06 #37
Op 2006-01-14, Mike Meyer schreef <mw*@mired.org> :
Antoon Pardon <ap*****@forel. vub.ac.be> writes:
If you
want to argue that the builtin sets should do that, you can - but
that's unrelated to the question of how the comparison operators
behave for the rest of the bulitin types.

What I argue is that there is no single order for a specific type.


I think that depends on your definition of type, but let it go.
There can be an order that is most usefull in general but which order
is usefull at a specific point depends on the context.


Yes. So what? Does this fact suggest some change to Python that would
improve it? If so, you need to mention it. If not, why bring it up at
all?


I did mention it, you even asked a use case and I gave it. What more
do you want?

--
Antoon Pardon
Jan 16 '06 #38

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4666
by: Edward | last post by:
SQL 7.0 I have a form in ASP.NET and I want to write the values to the SQL Server tables. The tables are Customer and Address tables. There will be an insert into the Customer table, and I need to use the Identity of this inserted record for the Foreign Key in the Address table insert.
5
8202
by: DBA | last post by:
I have an identity field on a table in SQL Server. The identity seed is 1 and the identity increment is 1. If I remove a record from this table, the identity sequence is broken. For example: Table contents prior to record delete: Fname(varchar), Lname (varchar), row_id (identity) -------------------------------------------------- Smith, Jane, 1 Smith, Tom, 2 Jones, Mark 3
5
9857
by: grzes | last post by:
MS SQL Server 2000. My case is: I have the table T with primary key calling __recid int without identity property. This table includes a lot of records (about 1000000). I need to convert __recid's data type to IDENTITY. As you know sql sentence: "alter table T alter column __recid int IDENTITY not null" does not work with not-empty tables. I use the SQL Enterprise Manager which can convert the field __recid into identity but I need...
2
1770
by: Devesh Aggarwal | last post by:
Hi, I have a backup and restore module in my project. The backup uses a typed dataset object (XSD) to get the data from database and creates a xml file as the backup file (using the WriteXml method of dataset). When doing the restore i have to overwrite the data from xml back to database. these are the steps that i follow. 1. get the data from database.
5
4011
by: Eugene | last post by:
I have a table EugeneTest(id_num, fname, minit, lname) where field "id_num" is type IDENTITY and has UNIQUE constraint Let's say 2 user execute this code at the same time: DECLARE @return integer use EugeneTest INSERT employees ( fname, minit, lname) VALUES
4
41598
by: brent.ryan | last post by:
How do I get the next int value for a column before I do an insert in MY SQL Server 2000? I'm currently using Oracle sequence and doing something like: select seq.nextval from dual; Then I do my insert into 3 different table all using the same uniqueID. I can't use the @@identity function because my application uses a connection pool and it's not garanteed that a connection won't be used
1
2271
by: Peter Morris [Droopy eyes software] | last post by:
Hi all In my login form (forms authentication) I check that the login is valid, retrieve an "Author" object, and keep track of the author's roles. string roles; if (author.IsAdministrator) roles = new string {"Admin", "Member"}; else roles = new string {"Member"};
3
4509
by: Dan | last post by:
I'm writing a record from an asp.net page to SQL Server. After the insert I'm selecting @@identity to return the ID of the record that I just wrote. It worked fine until I typed a semicolon into one of the string fields to be inserted. The string fields are inside single quotes in the INSERT command. With the semicolon in the string, the record is written correctly including the semicolon, but the identity is not returned. Without a...
3
2359
by: Rob | last post by:
Hi all, I have a bit of a complicated question, hope we have an SQL guru out there that can help us solve this killer problem. Due to the size of SQL Database we have (largest in the US), we try to pre-process large data files in IO until we are ready to insert directly into the database via BCP (quick, no constraints, no mess... well um that's the problem)
13
5799
by: PinkBishop | last post by:
I am using VS 2005 with a formview control trying to insert a record to my access db. The data is submitted to the main table no problem, but I need to carry the catID to the bridge table CatalogImage where imgID also needs to be placed. Below is my code behind to carry the catID using the Select @@Identity and insert imgID to the bridge table. No data is being entered into the bridge table.
0
9554
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9376
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10136
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9988
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7358
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6640
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3911
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3509
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.