[Python-3000] Betas today - I hope

Georg Brandl g.brandl at gmx.net
Fri Jun 13 15:18:24 CEST 2008


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



More information about the Python-3000 mailing list