[Cython] AddTraceback() slows down generators

Stefan Behnel stefan_ml at behnel.de
Sun Jan 29 13:10:10 CET 2012


Stefan Behnel, 28.01.2012 21:14:
> mark florisson, 28.01.2012 20:07:
>> On 28 January 2012 18:38, Stefan Behnel wrote:
>>> Stefan Behnel, 27.01.2012 09:02:
>>>> any exception *propagation* is
>>>> still substantially slower than necessary, and that's a general issue.
>>>
>>> Here's a general take on a code object cache for exception propagation.
>>> [...]
>> Nice. I have a question, couldn't you save the frame object instead of
>> the code object?
> 
> Technically, yes. However, eventually, I'd like to make the CodeObject
> constant for the whole function and let CPython calculate the Python code
> source line based on the frame's "f_lasti" field when the line number is
> actually accessed.
> 
> For now, I wouldn't mind cashing the whole frame until the above
> optimisation gets implemented.

Actually, I was wrong. The frame object cannot be cached because it is
mutable and even gets modified when building the stack trace call
hierarchy. So caching the frame instance may have user visible side effects.

Stefan


More information about the cython-devel mailing list