robertwb / issues-import-test

0 stars 0 forks source link

Avoid redundant calls to PyThreadState_GET() #1020

Closed robertwb closed 9 years ago

robertwb commented 9 years ago

PyThreadState_GET() isn't as cheap as it might look and calling it multiple times within the same function (especially in try-except/finally) is redundant. Its value could be stored in a local variable on first access and reused. Needs support in OpenMP code (-> thread-local variable), though, so not sure if it's really worth it overall.

Migrated from http://trac.cython.org/ticket/868

robertwb commented 9 years ago

scoder changed milestone from wishlist to 0.24 owner from somebody to scoder status from new to assigned Most of this is implemented in this and the subsequent commits: https://github.com/cython/cython/commit/832da3bfc940e961b6ea05d3d3c6692b599008b3

It could be further improved by keeping the pointer across try-except/finally clauses if there was no intermediate yield point, but this should already be an improvement. Thus closing the ticket given the lack of proof that there is need for more.

robertwb commented 9 years ago

scoder changed resolution to fixed status from assigned to closed