Dec-06-2018, 12:01 PM
In CPython it is agreed that id's (in effect addresses) of objects with values > 256 should be different.
When using the Python prompt in a terminal this is exactly what happens. Doing the same by running a script with the same Python contents gives identical id's.
Python 3 Prompt
Script test.py
python3 /tmp/test.py
139835321420368
139835321420368
Can anyone shine some light on this please?
When using the Python prompt in a terminal this is exactly what happens. Doing the same by running a script with the same Python contents gives identical id's.
Python 3 Prompt
1 2 3 4 5 6 |
>>> a = 500 >>> b = 500 >>> print ( id (a)) 139745079475056 >>> print ( id (b)) 139745079475248 |
python3 /tmp/test.py
139835321420368
139835321420368
Can anyone shine some light on this please?