[pypy-dev] long.__itemsize__

Armin Rigo arigo at tunes.org
Tue Dec 21 12:37:00 CET 2010


On Tue, Dec 21, 2010 at 9:58 AM, Arnd Rechenburg
<Arnd.Rechenburg at tomtom.com> wrote:
> In my code I need something like
> long.__itemsize__
> in Python.

I suppose the question is "why"?  This is supposed to be the size in
bytes occupied by one "element" of the type, and one element of "long"
happens to be 15 bits, so that's why long.__itemsize__ is 2.  It has
no other meaning.  If you are interested in an estimate of how many
bytes some actual object takes, we have some functions in the 'gc'
module, but even that is incomplete -- there are cases were it's hard
to come up with a definitive answer, like objects based on "mapdicts".

A bientôt,


More information about the Pypy-dev mailing list