-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SETUP_WITH #50351
Comments
This patch condenses the many current opcodes used to start a with |
Performance numbers: With patch: $ ./python.exe -m timeit -s 'import thread; l = thread.allocate_lock()'
'with l: pass'
1000000 loops, best of 3: 1.99 usec per loop Without: |
I'm not sure I understand the point of PyInstance_Check() in You should bump the bytecode version in import.c. By the way, there are some "with" tests in pybench (you can run them |
2009/5/24 Antoine Pitrou <report@bugs.python.org>:
_PyObject_LookupSpecial doesn't understand classic classes.
Ok Thanks. |
Endly, in compile.c, it seems the stack effect of SETUP_WITH should be |
SETUP_WITH3.patch looks good to me. |
Applied in r72912. |
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 ? |
2010/12/4 Thomas Vander Stichele <report@bugs.python.org>:
Very much not. |
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, |
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 |
LIST_APPEND was renumbered because it gained an argument. |
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. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: