Antoine Pitrou schrieb:
Hi,
Georg Brandl <g.brandl <at> gmx.net> writes:
I would argue that the __enter__ and __exit__ behavior should be changed too.
The reason for the current behavior is this:
[...]
IOW, when "with" is compiled, the attributes are retrieved using bytecode.
It wouldn't be hard to have a WITH_SETUP opcode (along with the already
existing WITH_CLEANUP) that would make the bytecode read like:
It's not really a change in behaviour, just an optimization, isn't it?
It is a change, since the new opcode would look up __enter__ and __exit__
via _PyType_Lookup instead of using PyObject_GetAttr like LOAD_ATTR does.
Georg
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com