Re: Interesting list Validity (True/False)



En Tue, 15 May 2007 01:37:07 -0300, mensanator@xxxxxxx <mensanator@xxxxxxx> escribió:

> <quote emphasis added>
> Sec 2.2.3:
> Objects of different types, *--->except<---* different numeric types
> and different string types, never compare equal;
> </quote>

The exceptions you mean are not exceptions to "'X==Y' means 'X equals
Y'".

I never said they were. I said they were exceptions to
"Obbjects of different types never compare equal".

This is an unfortunate wording, and perhaps should read: "For most builtin types, objects of different types never compare equal; such objects are ordered consistently but arbitrarily (so that sorting a heterogeneous sequence yields a consistent result). The exceptions being different numeric types and different string types, that have a special treatment; see section 5.9 in the Reference Manual for details."

And said section 5.9 should be updated too: "The objects need not have the same type. If both are numbers or strings, they are converted to a common type. Otherwise, objects of different builtin types always compare unequal, and are ordered consistently but arbitrarily. You can control comparison behavior of objects of non-builtin types by defining a __cmp__ method or rich comparison methods like __gt__, described in section 3.4."

I hope this helps a bit. Your performance issues don't have to do with the *definition* of equal or not equal, only with how someone decided to write the mpz class.

--
Gabriel Genellina

.



Relevant Pages

  • Re: Help! Need to sorted collection accessible by key
    ... Equals() and GetHashCode, then return the hashcode of the key you want ... access with, and compare by the one you want to order by, and put it ... If two items that compare equal using the _hasher key do not compare ... hash to the same bucket in the hash table but will not be equal to ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Interesting list Validity (True/False)
    ... Python to compare those strings equal. ... "a equals d" is true. ... There may or may not be any coercion involved.) ... And if you ask any mathematician, he'll say that is equal to. ...
    (comp.lang.python)
  • Re: Reading specific memory address into variable
    ... cons_pi and it equals 3.14159265358979. ... for how many times they want to do that calculation to figure out pi (4/1 - ... which is where I was stuck trying to figure out a way to compare the two ... incrementing the accuracy variable by 1 and incrementing the multiply ...
    (comp.lang.cpp)
  • Re: Interesting list Validity (True/False)
    ... The exceptions you mean are not exceptions to "'X==Y' means 'X equals ... "Obbjects of different types never compare equal". ... Are you implying that I can't interchange and ...
    (comp.lang.python)
  • Some Opinions on this code block ?
    ... diverse, including enums, basic system types, arrays and nested types. ... for equals, compare ... ... code block in and then run it. ...
    (microsoft.public.dotnet.languages.csharp)