[Tutor] object size in python is in what units?

Marc Tompkins marc.tompkins at gmail.com
Tue Jul 23 10:19:29 CEST 2013


On Tue, Jul 23, 2013 at 1:13 AM, Marc Tompkins <marc.tompkins at gmail.com>wrote:


> As an experiment, I added a couple of extra methods and attributes to the
> Kronk class, but it didn't change anything - IDs still incremented by 40
> each time.  eryksun will no doubt chime in to tell us exactly how object
> IDs are derived in cPython, but I'll go out on a limb and say that they
> have nothing to do with the size of the object; also that one would be very
> silly to make a program rely in any way on predicting the next ID, since
> external factors may throw off the calculations (as when I invoked your
> original script from inside PyScripter).  All that you can rely on is that
> each unique object (i.e. doesn't pass an "is" comparison with any other
> object) has a unique ID... and, for all I know, not even that.
>

A couple of clarifications I wish I'd made before hitting Send:  I
shouldn't have said that IDs are "derived" or "calculated"; they're
"assigned", presumably on a first-come, first-served basis; when I said
"external factors may throw off the calculations" I meant "may make your
calculations non-congruent with reality".
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130723/62c338ec/attachment.html>


More information about the Tutor mailing list