Repository navigation
gh-105481: Generate the opcode lists in dis from data extracted from bytecodes.c #106758
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
Changes from 1 commit
36a7d56
75019ca
494680a
24786fb
563b431
227756f
1b13b96
0f5ae32
289fad1
598ba2a
d2d355e
27eb2cc
998024a
ffa4ee3
ce76a60
4194a12
6b8c46b
e15f7d5
21fe0a4
75795db
1a0a2b2
f530469
71ffe34
d525c53
5e1c4a4
6077263
98ba11f
cc8e5e1
31dbfec
1abf6ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
This reverts commit 1a0a2b2.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,12 @@ | |
| """ | ||
|
|
||
|
|
||
| __all__ = ["cmp_op", "opname", "opmap", "HAVE_ARGUMENT", "EXTENDED_ARG"] | ||
| # Note that __all__ is further extended below | ||
| __all__ = ["cmp_op", "opname", "opmap", "stack_effect", "hascompare", | ||
| "HAVE_ARGUMENT", "EXTENDED_ARG"] | ||
|
|
||
| import _opcode | ||
| from _opcode import stack_effect | ||
|
|
||
| import sys | ||
| # The build uses older versions of Python which do not have _opcode_metadata | ||
|
|
@@ -236,6 +241,24 @@ def pseudo_op(name, op, real_ops): | |
| for op, i in opmap.items(): | ||
| opname[i] = op | ||
|
|
||
| # The build uses older versions of Python which do not have _opcode.has_* functions | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is quite mysterious. IIRC Brandt (?) wrote some hack that reads opcode.py and then execs it? But I can't find it.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, in Tools/build/generate_opcode_h.py. But when it execs opcode.py that tries to import _opcode and call its has_arg etc to construct the oplists (which are not used during the build). Ideally we should just get rid of generate_opcode_h.py if we can.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we don't need to import _opcode into opcode at all. We can just import it directly into dis (which is not used by any build scripts). I'll try that. |
||
| if sys.version_info[:2] >= (3, 13): | ||
| # These lists are documented as part of the dis module's API | ||
| hasarg = [op for op in opmap.values() if _opcode.has_arg(op)] | ||
| hasconst = [op for op in opmap.values() if _opcode.has_const(op)] | ||
| hasname = [op for op in opmap.values() if _opcode.has_name(op)] | ||
| hasjump = [op for op in opmap.values() if _opcode.has_jump(op)] | ||
| hasjrel = hasjump # for backward compatibility | ||
| hasjabs = [] | ||
|
iritkatriel marked this conversation as resolved.
|
||
| hasfree = [op for op in opmap.values() if _opcode.has_free(op)] | ||
| haslocal = [op for op in opmap.values() if _opcode.has_local(op)] | ||
| hasexc = [op for op in opmap.values() if _opcode.has_exc(op)] | ||
|
|
||
| __all__.extend(["hasarg", "hasconst", "hasname", "hasjump", "hasjrel", | ||
| "hasjabs", "hasfree", "haslocal", "hasexc"]) | ||
|
iritkatriel marked this conversation as resolved.
|
||
|
|
||
| hascompare = [opmap["COMPARE_OP"]] | ||
|
|
||
| _nb_ops = [ | ||
| ("NB_ADD", "+"), | ||
| ("NB_AND", "&"), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.