Python Forum
Does the integer implementation matter?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Does the integer implementation matter?
#1
Some integers are stored in a table, so two variables assigned to integers might have the same address, or they might have different addresses. This comes up periodically on these forums, most recently here.

I don't care why this happens.

My question is: does it matter? I think I have been programming Python for 17 years now, and never have the details of the integer implementation mattered to any of my programs. Has it ever mattered to any of your code? Can someone post a code snippet where it did matter?
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#2
I guess it matters if you start worrying about where the python objects are really stored in memory. For example if you're computing the actual size of python objects
>>> from pympler import asizeof
>>> x = 80000
>>> y = 80000
>>> 
>>> asizeof.asizeof([x, y])
144
>>> asizeof.asizeof([x, x])
112
>>> x = 5
>>> y = 5
>>> asizeof.asizeof([x, y])
112
Reply
#3
Don't think it matter so much at all,but when people discover that stuff eg integer in Python can point to same place.
Then get Thread where explain this with id() and other stuff.
[Image: python-gc-4-638.jpg?cb=1400908049]
After knowing this probably never need to worry about this again in regular Python programming.
One of the strength of Python is that memory management Doh is done automatically,so we don't need to mess with it Cool
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Exercises -- Who does them? Do they matter? pav1983 5 2,343 Jun-02-2020, 09:32 PM
Last Post: pav1983
  About integer objects vs integer values Nwb 18 7,829 Apr-29-2019, 07:41 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020