(original) (raw)
On 9 August 2016 at 23:26, Nick Coghlan <ncoghlan@gmail.com> wrote:
On 9 August 2016 at 06:18, Guido van Rossum <guido@python.org> wrote:I think Nick would be interested in understanding why this is the case. What does the decorator do that could be so expensive?Reviewing https://hg.python.org/cpython/file/default/Lib/contextlib. py#l57, Chris's analysis seems plausible to me
Sorry Wolfgang - I missed that Chris was expanding on a comparison you initially made!
Either way, I agree that aspect does make up the bulk of the difference in speed, so moving to C likely wouldn't help much. However, the speed difference relative to the simpler warppers is far less defensible - I think there are some opportunities for improvement there, especially around moving introspection work out of \_GeneratorContextManager.\_\_init\_\_ and into the contextmanager decorator itself.
Either way, I agree that aspect does make up the bulk of the difference in speed, so moving to C likely wouldn't help much. However, the speed difference relative to the simpler warppers is far less defensible - I think there are some opportunities for improvement there, especially around moving introspection work out of \_GeneratorContextManager.\_\_init\_\_ and into the contextmanager decorator itself.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia