Dave Malcolm <dmalc...@redhat.com> added the comment: Attaching a probably over-simplistic attempt at this patch, against the py3k branch.
This patch attempts to extend the replacement of LOAD_CONST, ...., LOAD_CONST, BUILD_LIST, COMPARE_OP(in) with LOAD_CONST(tuple), COMPAREOP(in) so that it also replaces: LOAD_CONST, ...., LOAD_CONST, BUILD_SET, COMPARE_OP(in) with LOAD_CONST(tuple), COMPAREOP(in) i.e. using a tuple, not a frozenset (on the grounds that the "in" conditions should at least still work); caveat: I'm relatively new to the innards of this code. With this patch: >>> dis.dis(lambda o: o in {1,2,3}) 1 0 LOAD_FAST 0 (o) 3 LOAD_CONST 3 ((1, 2, 3)) 6 COMPARE_OP 6 (in) 9 RETURN_VALUE but: >>> dis.dis(lambda o: o in {1,2,3,3,2,1}) 1 0 LOAD_FAST 0 (o) 3 LOAD_CONST 3 ((1, 2, 3, 3, 2, 1)) 6 COMPARE_OP 6 (in) 9 RETURN_VALUE Is it worth me working on a rewrite to use a frozenset. Hope this is helpful Dave ---------- keywords: +patch nosy: +dmalcolm Added file: http://bugs.python.org/file15840/simple-optimization-of-BUILD_SET-COMPARE_OP(IN)-to-LOAD_CONST(tuple)_COMPARE_OP(IN)-py3k.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue6690> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com