
On 15/02/12 21:09, Yury Selivanov wrote:
Hello Mark,
First, I've back-ported your patch on python 3.2.2 (which was relatively easy). Almost all tests pass, and those that don't are always failing on my machine if I remember. The patch can be found here: http://goo.gl/nSzzY
Then, I compared memory footprint of one of our applications (300,000 LOC) and saw it about 6% less than on vanilla python 3.2.2 (660 MB of reserved process memory compared to 702 MB; Linux Gentoo 64bit) The application is written in heavy OOP style (for instance, ~1000 classes are generated by our ORM on the fly, and there are approximately the same amount of hand-written ones) so I hoped for a much bigger saving.
As for the patch itself I found one use-case, where python with the patch behaves differently::
class Foo: def __init__(self, msg): self.msg = msg
f = Foo('123')
class _str(str): pass
print(f.msg) print(getattr(f, _str('msg')))
The above snippet works perfectly on vanilla py3.2, but fails on the patched one (even on 3.3 compiled from your 'cpython_new_dict' branch) I'm not sure that it's a valid code, though. If not, then we need to fix some python internals to add exact type check in 'getattr', in the 'operator.getattr', etc. And if it is - your patch needs to be fixed. In any case, I propose to add the above code to the python test-suite, with either expecting a result or an exception.
Your code is valid, the bug is in my code. I've fixed and updated the repository. More tests to be added later. Cheers, Mark.