Re: negative numbers are not equal...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Terry Reedy

    Re: negative numbers are not equal...

    When you ask the interpreter to create an immutable object with a
    particular value, it may at its discretion, to conserve space and
    possibly conserve time, return an existing object with that same value.
    This is documented somewhere in the reference.

    The result of comparing two 'different' objects of the same value with
    'is' depends on whether or not the interpreter used that option. And
    such usage is an implementation and version specific detail. Aside from
    that, the behavior of two immutable objects with the same value is
    identical to that of two references to the same object. The benefits of
    the optimization are considered to outweigh the cost of confusing new
    Python programmers ;-)

    tjr

Working...