[Python-Dev] Int FutureWarnings and other 2.4 TODOs (original) (raw)

Guido van Rossum guido at python.org
Fri Dec 5 12:26:09 EST 2003


BTW, using pymalloc instead wouldn't eliminate that allocated memory is never returned to the OS. pymalloc grabs large "arenas" from malloc(), and never free()s them. The fundamental difference is that pymalloc is type-agnostic: space gotten from pymalloc for, say, a dict, can later be reused for, say, a string. pymalloc's freelists are segregated by raw memory size rather than by type, and a given chunk of pymalloc memory may even move from one size list to another (any number of times).

But there aren't a lot of other objects that fit in the size of an int, right? I know of no other types that are <= 12 bytes on a 32-bit machine, and assuming pymalloc rounds up, only one that is <= 16 (float). There may be some obscure ones (super may be only 16 bytes too) but they'll never need that many instances to fill the void left behind by range(10000000).

(I'm assuming that pymalloc doesn't join adjacent small blocks to form a larger block -- that way lies a full malloc reimplementation, and what's the point of that...)

--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-Dev mailing list