[Python-Dev] Looking for master thesis ideas involving Python

Armin Rigo arigo at tunes.org
Sun Nov 2 18:35:16 EST 2003

Hello Martin,

On Sun, Nov 02, 2003 at 08:05:55PM +0100, Martin v. L?wis wrote:
> > > More than that in the good cases.  Something I forgot was that you'd
> > > probably have to knock variable length types on the head.
> > 
> > Why?
> Assuming "to knock on the head" means "to put an end to":
> If you put all objects of the same type into a pool, you really want
> all objects to have the same side, inside a pool. With that
> assumption, garbage objects can be reallocated without causing
> fragmentation. If objects in a pool have different sizes, it is not
> possible to have an efficient reallocation strategy.

"Not easy" would have been more appropriate.  It is still basically what
malloc() does.

One way would be to use Python's current memory allocator, by adapting it to
sort objects into pools not only according to size but also according to type.  
What seems to me like a good solution would be to use one relatively large
"arena" per type and Python's memory allocator to subdivide each arena.  If
each arena starts at a pointer address which is properly aligned, then
*(p&MASK) gives you the type of any object, and possibly even without much
cache-miss overhead because there are not so many arenas in total (probably
only 1-2 per type in common cases, and arenas can be large).

A bientot,


More information about the Python-Dev mailing list