[Cython] AddTraceback() slows down generators

mark florisson markflorisson88 at gmail.com
Sun Jan 29 13:30:50 CET 2012


On 29 January 2012 12:10, Stefan Behnel <stefan_ml at behnel.de> wrote:
> 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
> _______________________________________________
> cython-devel mailing list
> cython-devel at python.org
> http://mail.python.org/mailman/listinfo/cython-devel

Ah right, the f_back attribute?


More information about the cython-devel mailing list