[Python-ideas] Lessons from typing hinting Whoosh (PEP484)

Chris Angelico rosuav at gmail.com
Mon Nov 16 12:29:00 EST 2015


On Tue, Nov 17, 2015 at 4:19 AM, Andrew Barnert via Python-ideas
<python-ideas at python.org> wrote:
> The object will also be the same size as an int in memory (although it will pickle a little bigger).

To make that true, you have to use slots:

>>> import sys
>>> sys.getsizeof(12341234123412341234)
36
>>> class X(int): pass
...
>>> sys.getsizeof(X(12341234123412341234))
60
>>> class X(int): __slots__=()
...
>>> sys.getsizeof(X(12341234123412341234))
36

ChrisA


More information about the Python-ideas mailing list