[issue6101] SETUP_WITH
Thomas Vander Stichele thoma...@users.sourceforge.net added the comment: Maybe I am missing something, but why was it ok for this patch to move EXTENDED_ARGS from 143 to 145 ? I thought the numbers for opcodes were part of the ABI ? -- nosy: +thomasvs ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6101 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6101] SETUP_WITH
Benjamin Peterson benja...@python.org added the comment: 2010/12/4 Thomas Vander Stichele rep...@bugs.python.org: Thomas Vander Stichele thoma...@users.sourceforge.net added the comment: Maybe I am missing something, but why was it ok for this patch to move EXTENDED_ARGS from 143 to 145 ? I thought the numbers for opcodes were part of the ABI ? Very much not. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6101 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6101] SETUP_WITH
Thomas Vander Stichele thoma...@users.sourceforge.net added the comment: Really ? Is this documented somewhere ? Do you know of any other case where a number for an existing opcode was changed ? I can't find any so far. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6101 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6101] SETUP_WITH
Antoine Pitrou pit...@free.fr added the comment: Really ? Is this documented somewhere ? Do you know of any other case where a number for an existing opcode was changed ? I can't find any so far. Opcodes are an implementation detail. If you are fiddling with opcodes, how will your code work under Jython, IronPython or even PyPy? Besides, not only opcode numbers may change, but the semantics of a given opcode can change too (even if its number stays the same). So there's nothing stable you can rely on here. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6101 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6101] SETUP_WITH
Thomas Vander Stichele thoma...@users.sourceforge.net added the comment: Well, I just checked, and from 2.3 to 2.6 opcodes were only added, existing ones were never renumbered. 2.7 however reshuffled a bunch of them, for no apparent reason at all: $ diff -au opcodes-2.6 opcodes-2.7 --- opcodes-2.6 2010-12-04 20:47:19.110031279 +0100 +++ opcodes-2.7 2010-12-04 20:47:06.770611299 +0100 @@ -10,7 +10,6 @@ 12 UNARY_NOT 13 UNARY_CONVERT 15 UNARY_INVERT - 18 LIST_APPEND 19 BINARY_POWER 20 BINARY_MULTIPLY 21 BINARY_DIVIDE @@ -73,6 +72,7 @@ 91 DELETE_NAME 92 UNPACK_SEQUENCE 93 FOR_ITER + 94 LIST_APPEND 95 STORE_ATTR 96 DELETE_ATTR 97 STORE_GLOBAL @@ -82,15 +82,18 @@ 101 LOAD_NAME 102 BUILD_TUPLE 103 BUILD_LIST - 104 BUILD_MAP - 105 LOAD_ATTR - 106 COMPARE_OP - 107 IMPORT_NAME - 108 IMPORT_FROM + 104 BUILD_SET + 105 BUILD_MAP + 106 LOAD_ATTR + 107 COMPARE_OP + 108 IMPORT_NAME + 109 IMPORT_FROM 110 JUMP_FORWARD - 111 JUMP_IF_FALSE - 112 JUMP_IF_TRUE + 111 JUMP_IF_FALSE_OR_POP + 112 JUMP_IF_TRUE_OR_POP 113 JUMP_ABSOLUTE + 114 POP_JUMP_IF_FALSE + 115 POP_JUMP_IF_TRUE 116 LOAD_GLOBAL 119 CONTINUE_LOOP 120 SETUP_LOOP @@ -110,4 +113,7 @@ 140 CALL_FUNCTION_VAR 141 CALL_FUNCTION_KW 142 CALL_FUNCTION_VAR_KW - 143 EXTENDED_ARG + 143 SETUP_WITH + 145 EXTENDED_ARG + 146 SET_ADD + 147 MAP_ADD -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6101 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6101] SETUP_WITH
Antoine Pitrou pit...@free.fr added the comment: Well, I just checked, and from 2.3 to 2.6 opcodes were only added, existing ones were never renumbered. 2.7 however reshuffled a bunch of them, for no apparent reason at all: LIST_APPEND was renumbered because it gained an argument. There are also new opcodes in this list. Regardless, there is no guarantee about opcode numbering stability. You cannot infer such an expectation from previous behaviour. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6101 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6101] SETUP_WITH
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: Yes, someone went nuts with renumbering. That is allowed but was probably unnecessary. That being said, users of opcodes should really use the names in opcode.py instead of the numbers themselves. -- nosy: +rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6101 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6101] SETUP_WITH
Antoine Pitrou pit...@free.fr added the comment: SETUP_WITH3.patch looks good to me. -- resolution: - accepted stage: - commit review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6101 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6101] SETUP_WITH
Benjamin Peterson benja...@python.org added the comment: Applied in r72912. -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6101 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6101] SETUP_WITH
New submission from Benjamin Peterson benja...@python.org: This patch condenses the many current opcodes used to start a with statement into one, SETUP_WITH. I originally did this to properly lookup __enter__ and __exit__ as special methods. However, the patch also has the nice side effect of removing the need for a temporary variable. -- assignee: benjamin.peterson components: Interpreter Core files: SETUP_WITH.patch keywords: patch messages: 88293 nosy: benjamin.peterson priority: normal severity: normal status: open title: SETUP_WITH type: performance versions: Python 2.7, Python 3.2 Added file: http://bugs.python.org/file14060/SETUP_WITH.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6101 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6101] SETUP_WITH
Benjamin Peterson benja...@python.org added the comment: Performance numbers: With patch: $ ./python.exe -m timeit -s 'import thread; l = thread.allocate_lock()' 'with l: pass' 100 loops, best of 3: 1.99 usec per loop Without: 10 loops, best of 3: 2.15 usec per loop -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6101 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6101] SETUP_WITH
Antoine Pitrou pit...@free.fr added the comment: I'm not sure I understand the point of PyInstance_Check() in lookup_special(). You should bump the bytecode version in import.c. By the way, there are some with tests in pybench (you can run them using -t With). -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6101 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6101] SETUP_WITH
Benjamin Peterson benja...@python.org added the comment: 2009/5/24 Antoine Pitrou rep...@bugs.python.org: Antoine Pitrou pit...@free.fr added the comment: I'm not sure I understand the point of PyInstance_Check() in lookup_special(). _PyObject_LookupSpecial doesn't understand classic classes. You should bump the bytecode version in import.c. Ok Thanks. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6101 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6101] SETUP_WITH
Antoine Pitrou pit...@free.fr added the comment: Endly, in compile.c, it seems the stack effect of SETUP_WITH should be 1, not 3 (only one value is pushed onto the stack). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6101 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6101] SETUP_WITH
Changes by Benjamin Peterson benja...@python.org: Added file: http://bugs.python.org/file14061/SETUP_WITH2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6101 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6101] SETUP_WITH
Changes by Benjamin Peterson benja...@python.org: Added file: http://bugs.python.org/file14062/SETUP_WITH3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6101 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com