2016-05-16 17:55 GMT+02:00 Meador Inge <mead...@gmail.com>: > On Sun, May 15, 2016 at 2:23 AM, Cesare Di Mauro < > cesare.di.ma...@gmail.com> wrote: > > >> Just one thing that comes to my mind: is the stack depth calculation >> routine changed? It was suboptimal, and calculating a better number >> decreases stack allocation, and increases the frame usage. >> > > This is still a problem and came up again recently: > > http://bugs.python.org/issue26549 > > -- Meador >
I saw the last two comments of the issues: this is what I was talking about (in particular the issue opened by Armin applies). However there's another case where the situation is even worse. Let me show a small reproducer: def test(self): for i in range(self.count): with self: pass The stack size reported by Python 2.7.11: >>> test.__code__.co_stacksize 6 Adding another with statement: >>> test.__code__.co_stacksize 7 But unfortunately with Python 3.5.1 the problematic is much worse: >>> test.__code__.co_stacksize 10 >>> test.__code__.co_stacksize 17 Here the situation is exacerbated by the fact that the WITH_CLEANUP instruction of Python 2.x was split into two (WITH_CLEANUP_START and WITH_CLEANUP_FINISH) in some Python 3 release. I don't know why two different instructions were introduced, but IMO it's better to have one instruction which handles all code finalization of the with statement, at least in this case. If there are other scenarios where two different instructions are needed, then ad-hoc instructions like those can be used. Regards, Cesare
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com