robertwb / issues-import-test

0 stars 0 forks source link

Avoid redundant calls to PyThreadState_GET() #101

Closed robertwb closed 7 years ago

robertwb commented 7 years ago

Reported by scoder on 19 Sep 2015 20:38 UTC 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 7 years ago

Comment by scoder on 28 Sep 2015 16:43 UTC 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 7 years ago

Modified by scoder on 28 Sep 2015 16:44 UTC