[issue640] Possible optimization in FOR_ITER on a constant tuple

New submission from Alex Gaynor <alex.gaynor@gmail.com>: Given: for x in (1, 2, 3): i += x We currently generate: FOR_ITER to 47 guard(i5 is 1) guard(guard_class(p7, 146344448)) p14 = ((pypy.objspace.std.iterobject.W_FastTupleIterObject)p7).inst_tupleitems guard(guard_nonnull(p14)) i15 = ((pypy.objspace.std.iterobject.W_AbstractSeqIterObject)p7).inst_index i16 = arraylen_gc(p14) i17 = i15 >= i16 guard(i17 is false) p18 = getarrayitem_gc(p14, i15) i20 = i15 + 1 This is slightly inefficient in a few places, the getitem, for tupleitems, could be eliminated, as could the arraylen. ---------- effort: ??? messages: 2155 nosy: agaynor, pypy-issue priority: wish release: ??? status: unread title: Possible optimization in FOR_ITER on a constant tuple _______________________________________________________ PyPy development tracker <pypy-dev-issue@codespeak.net> <https://codespeak.net/issue/pypy-dev/issue640> _______________________________________________________

Carl Friedrich Bolz <cfbolz@gmx.de> added the comment: we do better on this nowadays. ---------- nosy: +cfbolz status: chatting -> resolved ________________________________________ PyPy bug tracker <tracker@bugs.pypy.org> <https://bugs.pypy.org/issue640> ________________________________________
participants (2)
-
Alex Gaynor
-
Carl Friedrich Bolz