
At 02:10 PM 10/31/03 +0000, Michael Hudson wrote:
"Phillip J. Eby" <pje@telecommunity.com> writes:
Here's my crazy idea that's been knocking around my head for a while. I wonder if anyone can shoot in down in flames.
Remove the ob_type field from all PyObjects. Make pymalloc mandatory, make it use type specific pools and store a pointer to the type object at the start of each pool.
How would you get from the pointer to the pool head?
Did you read the rest of my mail? Maybe I was too terse, but my
Yes, and yes. :)
thinking was that the pools are aligned on a known size boundary (e.g. 4K) so to get to the head you just mask off the 12 (or whatever) least significant bits.
Ah. But since even the most trivial of Python operations require access to the type, wouldn't this take longer? I mean, for every ob->ob_type->tp_whatever you'll now have something like *(ob & mask)->tp_whatever. So there are still two memory acesses, but now there's a bitmasking operation added in. I suppose that for some object types you could be getting a 12-25% decrease in memory use for the base object, though.