[issue30416] constant folding opens compiler to quadratic time hashing

Andrew Dalke report at bugs.python.org
Sun May 21 22:42:45 EDT 2017


Andrew Dalke added the comment:

A complex solution is to stop constant folding when there are more than a few levels of tuples. I suspect there aren't that many cases where there are more than 5 levels of tuples and where constant creation can't simply be assigned and used as a module variable.

This solution would become even more complex should constant propagation be supported.

Another option is to check the value about to be added to co_consts. If it is a container, then check if it would require more than a few levels of hash calls. If so, then simply add it without ensuring uniqueness.

This could be implemented because the compiler could be told how to carry out that check for the handful of supported container types.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30416>
_______________________________________


More information about the Python-bugs-list mailing list