[New-bugs-announce] [issue30293] Peephole binops folding can lead to memory and bytecache ballooning

Martijn Pieters report at bugs.python.org
Sat May 6 15:04:17 EDT 2017


New submission from Martijn Pieters:

The following expression produces 127MB in constants in `co_consts` due to two 63.5MB integer objects produced when folding:

    ((200*200 - 2) & ((1 << 500000000) - 1)) + ((200*200 - 2) >> 500000000)

The optimizer already does not store optimized *sequences* of more than 20 elements to avoid making bytecode files too large:

   If the new constant is a sequence, only folds when the size
   is below a threshold value.  That keeps pyc files from
   becoming large in the presence of code like:  (None,)*1000.

Perhaps the same should be extended to number objects?

Context: https://stackoverflow.com/questions/43823807/why-does-using-arguments-make-this-function-so-much-slower

----------
messages: 293167
nosy: mjpieters
priority: normal
severity: normal
status: open
title: Peephole binops folding can lead to memory and bytecache ballooning

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


More information about the New-bugs-announce mailing list