Why this difference?
Paul Anton Letnes
paul.anton.letnes at gmail.com
Thu Feb 24 07:58:28 EST 2011
More information about the Python-list mailing list
Thu Feb 24 07:58:28 EST 2011
- Previous message (by thread): Why this difference?
- Next message (by thread): Why this difference?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Den 24.02.11 13.41, skrev n00m: > The 1st "False" is not surprising for me. > It's the 2nd "True" is a bit hmmm... ok, it doesn't matter > ====================== > Have a nice day! I am no expert, but I think python re-uses some integer and string objects. For instance, if you create the object int(2) it may be re-used later if you have several 2 objects in your code. This is to save some memory, or some other performance hack. Don't rely on it. For instance: >>> a = 100 >>> b = 100 >>> a is b True >>> a = 2**60 >>> b = 2**60 >>> a is b False Strange, but it's just like this! Paul
- Previous message (by thread): Why this difference?
- Next message (by thread): Why this difference?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list