On 9/25/2012 2:17 PM, Oscar Benjamin wrote:
I don't know whether it would be better or worse but it might be worth
seeing what happens if you replace the FileContext objects with tuples.
I originally used a string, and it was slightly better since you don't
have the object overhead, but I wanted to code to an interface for the
context information so started a Context abstract class that FileContext
inherits from (both have __slots__ set). Using an object without
__slots__ set was a disaster. However, the difference between a string
and an object with __slots__ isn't severe.
I can't see anything wrong with that but then I'm not sure if the
lambda function always keeps its frame alive. If there's only that one
line in the __init__ function then I'd expect it to be fine.
That's it, I'm afraid.
Perhaps you could see what objgraph comes up with:
http://pypi.python.org/pypi/objgraph
So far as I know objgraph doesn't tell you how big objects are but it
does give a nice graphical representation of which objects are alive
and which other objects they are referenced by. You might find that
some other object is kept alive that you didn't expect.
I'll give it a shot and see what happens.
Cheers, MrsEntity
--
http://mail.python.org/mailman/listinfo/python-list