[issue31753] Unnecessary closure in ast.literal_eval

Aaron Hall report at bugs.python.org
Wed Oct 11 10:31:07 EDT 2017


Aaron Hall <aaronchall at yahoo.com> added the comment:

So... moving the closure (which may be called recursively) to the global scope actually does improve performance (for small cases, about 10% - larger cases amortize the cost of the closure being built, but in a 100 item dictionary, still about 4% faster to extricate the closure). So I'm reopening. Also suggesting we consider doing this with other functions if they are unnecessarily closures in the module.

`fix_missing_locations` appears to be another such function with an unnecessary closure.

the closure in `dump` cannot be removed without some rewriting of the signature, as it uses variables it closes over. Not sure this would be worth it.

----------
resolution: rejected -> 
status: closed -> open

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31753>
_______________________________________


More information about the Python-bugs-list mailing list