This repository has been archived by the owner on Jan 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
๐๏ธ Python ๅ็ๆฌๅญ่็ ๅทฎๅผ่กจๆ ผ #118
Comments
Closed
่ดดไธไธ่กจๆ ผ็ๆ็ไปฃ็ ๏ผๆนไพฟไปฅๅ็ป่ฎก Python 3.13 ็ญๆฐ็ๆฌ็ไฟกๆฏ ๆๅๅญ่็ ไฟกๆฏๅจไธๅ็ๆฌ็ dis ๆๆกฃๆต่งๅจๆงๅถๅฐไธญ่ฟ่กๅฆไธ่ๆฌ๏ผไปฅๆๅ้่ฆ็ไฟกๆฏ JSON.stringify([...document.querySelectorAll(".opcode")].map(dl => [dl.querySelector(".sig-name").innerText, dl.querySelector(".headerlink").href, dl.querySelector(".versionmodified.added")?.innerText.match(/New in version (\d\.\d+)/)[1], [...dl.querySelectorAll(".versionmodified.changed")].map(change => [change.innerText.match(/Changed in version (\d\.\d+):/)[1], change.parentElement.innerText])])) ็ป่ฎกไฟกๆฏๅฐๆๅๅพๅฐ็ๅญ่็ ็ฒ่ดดๅฐไธ้ข็่ๆฌไธญไปฅ็ป่ฎกไฟกๆฏ๏ผๅนถ็ๆ Markdown ่กจๆ ผ from __future__ import annotations
import json
from typing import Dict, TypedDict
py37_code_info = ${py37_code_info ...} # ๅจ่ฟ้็ฒ่ดดๆๅๅฐ็ไฟกๆฏ
py38_code_info = ${py38_code_info ...}
py39_code_info = ${py39_code_info ...}
py310_code_info = ${py310_code_info ...}
py311_code_info = ${py311_code_info ...}
code_info_map = {
"3.7": json.loads(py37_code_info),
"3.8": json.loads(py38_code_info),
"3.9": json.loads(py39_code_info),
"3.10": json.loads(py310_code_info),
"3.11": json.loads(py311_code_info),
}
py_versions = list(code_info_map.keys())
class InfoItem(TypedDict):
link: str
is_new: bool
change: str | None
InfoTable = Dict[str, Dict[str, InfoItem]]
def gen_info_table(code_info_map) -> InfoTable:
info_table: InfoTable = {}
for py_version, code_info in code_info_map.items():
for code, link, added_version, changes in code_info:
if code not in info_table:
info_table[code] = {}
if py_version not in info_table[code]:
info_table[code][py_version] = {}
current_cell = info_table[code][py_version]
current_cell["link"] = link
current_cell["is_new"] = added_version == py_version
current_cell["change"] = None
for change in changes:
changed_version, changed_description = change
if changed_version == py_version:
current_cell["change"] = changed_description
return info_table
def codegen(info_table):
markdown_output = ""
markdown_output += "| |"
for py_version in py_versions:
markdown_output += f" Python {py_version} |"
markdown_output += "\n"
markdown_output += "| :-: |"
for _ in py_versions:
markdown_output += f" :-: |"
markdown_output += "\n"
for code, code_info in info_table.items():
line = f"| `{code}` | "
for py_version in py_versions:
if py_version in code_info:
cell = code_info[py_version]
line += f"[โ
]({cell['link']})"
if cell["is_new"]:
line += "๐"
if cell["change"] is not None:
line += f"<br/>{cell['change']}"
line += " |"
else:
line += " โ |"
markdown_output += line + "\n"
return markdown_output
if __name__ == "__main__":
info_table = gen_info_table(code_info_map)
markdown_output = codegen(info_table)
with open("bytecode.md", "w") as f:
f.write(markdown_output) |
SigureMo
changed the title
ๅญ่็ ็ๆฌๅทฎๅผ่กจๆ ผ
๐๏ธ ๅญ่็ ็ๆฌๅทฎๅผ่กจๆ ผ
Aug 14, 2023
SigureMo
changed the title
๐๏ธ ๅญ่็ ็ๆฌๅทฎๅผ่กจๆ ผ
๐๏ธ Python ๅ็ๆฌๅญ่็ ๅทฎๅผ่กจๆ ผ
Aug 14, 2023
16 tasks
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
NOP
POP_TOP
ROT_TWO
ROT_THREE
ROT_FOUR
DUP_TOP
DUP_TOP_TWO
UNARY_POSITIVE
UNARY_NEGATIVE
UNARY_NOT
UNARY_INVERT
GET_ITER
GET_YIELD_FROM_ITER
BINARY_POWER
BINARY_MULTIPLY
BINARY_MATRIX_MULTIPLY
BINARY_FLOOR_DIVIDE
BINARY_TRUE_DIVIDE
BINARY_MODULO
BINARY_ADD
BINARY_SUBTRACT
BINARY_SUBSCR
BINARY_LSHIFT
BINARY_RSHIFT
BINARY_AND
BINARY_XOR
BINARY_OR
INPLACE_POWER
INPLACE_MULTIPLY
INPLACE_MATRIX_MULTIPLY
INPLACE_FLOOR_DIVIDE
INPLACE_TRUE_DIVIDE
INPLACE_MODULO
INPLACE_ADD
INPLACE_SUBTRACT
INPLACE_LSHIFT
INPLACE_RSHIFT
INPLACE_AND
INPLACE_XOR
INPLACE_OR
STORE_SUBSCR
DELETE_SUBSCR
GET_AWAITABLE
Changed in version 3.11: Previously, this instruction did not have an oparg.
GET_AITER
GET_ANEXT
END_ASYNC_FOR
Changed in version 3.11: Exception representation on the stack now consist of one, not three, items.
BEFORE_ASYNC_WITH
SETUP_ASYNC_WITH
PRINT_EXPR
SET_ADD
LIST_APPEND
MAP_ADD
Changed in version 3.8: Map value is TOS and map key is TOS1. Before, those were reversed.
RETURN_VALUE
YIELD_VALUE
Changed in version 3.12: oparg set to be the exception block depth, for efficient closing of generators.
YIELD_FROM
SETUP_ANNOTATIONS
IMPORT_STAR
POP_BLOCK
POP_EXCEPT
Changed in version 3.11: Exception representation on the stack now consist of one, not three, items.
POP_FINALLY
BEGIN_FINALLY
END_FINALLY
LOAD_BUILD_CLASS
SETUP_WITH
WITH_CLEANUP_START
WITH_CLEANUP_FINISH
STORE_NAME
DELETE_NAME
UNPACK_SEQUENCE
UNPACK_EX
STORE_ATTR
DELETE_ATTR
STORE_GLOBAL
DELETE_GLOBAL
LOAD_CONST
LOAD_NAME
BUILD_TUPLE
BUILD_LIST
BUILD_SET
BUILD_MAP
BUILD_CONST_KEY_MAP
BUILD_STRING
BUILD_TUPLE_UNPACK
BUILD_TUPLE_UNPACK_WITH_CALL
BUILD_LIST_UNPACK
BUILD_SET_UNPACK
BUILD_MAP_UNPACK
BUILD_MAP_UNPACK_WITH_CALL
LOAD_ATTR
Changed in version 3.12: If the low bit of namei is set, then a NULL or self is pushed to the stack before the attribute or unbound method respectively.
COMPARE_OP
IMPORT_NAME
IMPORT_FROM
JUMP_FORWARD
POP_JUMP_IF_TRUE
Changed in version 3.12: This is no longer a pseudo-instruction.
POP_JUMP_IF_FALSE
Changed in version 3.12: This is no longer a pseudo-instruction.
JUMP_IF_TRUE_OR_POP
Changed in version 3.11: The oparg is now a relative delta rather than an absolute target.
JUMP_IF_FALSE_OR_POP
Changed in version 3.11: The oparg is now a relative delta rather than an absolute target.
JUMP_ABSOLUTE
FOR_ITER
Changed in version 3.12: Up until 3.11 the iterator was popped when it was exhausted.
LOAD_GLOBAL
Changed in version 3.11: If the low bit of namei is set, then a NULL is pushed to the stack before the global variable.
SETUP_FINALLY
CALL_FINALLY
LOAD_FAST
Changed in version 3.12: This opcode is now only used in situations where the local variable is guaranteed to be initialized. It cannot raise UnboundLocalError.
STORE_FAST
DELETE_FAST
LOAD_CLOSURE
Changed in version 3.11: i is no longer offset by the length of co_varnames.
LOAD_DEREF
Changed in version 3.11: i is no longer offset by the length of co_varnames.
LOAD_CLASSDEREF
Changed in version 3.11: i is no longer offset by the length of co_varnames.
STORE_DEREF
Changed in version 3.11: i is no longer offset by the length of co_varnames.
DELETE_DEREF
Changed in version 3.11: i is no longer offset by the length of co_varnames.
RAISE_VARARGS
CALL_FUNCTION
CALL_FUNCTION_KW
CALL_FUNCTION_EX
LOAD_METHOD
CALL_METHOD
MAKE_FUNCTION
Changed in version 3.10: Flag value 0x04 is a tuple of strings instead of dictionary
Changed in version 3.11: Qualified name at TOS was removed.
BUILD_SLICE
EXTENDED_ARG
FORMAT_VALUE
HAVE_ARGUMENT
Changed in version 3.12: Pseudo instructions were added to the dis module, and for them it is not true that comparison with HAVE_ARGUMENT indicates whether they use their arg.
RERAISE
Changed in version 3.11: Exception representation on the stack now consist of one, not three, items.
WITH_EXCEPT_START
Changed in version 3.11: The
__exit__
function is in position 4 of the stack rather than 7. Exception representation on the stack now consist of one, not three, items.LOAD_ASSERTION_ERROR
LIST_TO_TUPLE
LIST_EXTEND
SET_UPDATE
DICT_UPDATE
DICT_MERGE
IS_OP
CONTAINS_OP
JUMP_IF_NOT_EXC_MATCH
COPY_DICT_WITHOUT_KEYS
GET_LEN
MATCH_MAPPING
MATCH_SEQUENCE
MATCH_KEYS
Changed in version 3.11: Previously, this instruction also pushed a boolean value indicating success (True) or failure (False).
MATCH_CLASS
Changed in version 3.11: Previously, this instruction also pushed a boolean value indicating success (True) or failure (False).
GEN_START
ROT_N
COPY
SWAP
CACHE
BINARY_OP
PUSH_EXC_INFO
CHECK_EXC_MATCH
CHECK_EG_MATCH
PREP_RERAISE_STAR
BEFORE_WITH
JUMP_BACKWARD
JUMP_BACKWARD_NO_INTERRUPT
POP_JUMP_FORWARD_IF_TRUE
POP_JUMP_BACKWARD_IF_TRUE
POP_JUMP_FORWARD_IF_FALSE
POP_JUMP_BACKWARD_IF_FALSE
POP_JUMP_FORWARD_IF_NOT_NONE
POP_JUMP_BACKWARD_IF_NOT_NONE
POP_JUMP_FORWARD_IF_NONE
POP_JUMP_BACKWARD_IF_NONE
MAKE_CELL
COPY_FREE_VARS
CALL
PRECALL
PUSH_NULL
KW_NAMES
RESUME
RETURN_GENERATOR
SEND
ASYNC_GEN_WRAP
END_FOR
BINARY_SLICE
STORE_SLICE
CLEANUP_THROW
RETURN_CONST
LOAD_LOCALS
LOAD_FROM_DICT_OR_GLOBALS
LOAD_SUPER_ATTR
POP_JUMP_IF_NOT_NONE
Changed in version 3.12: This is no longer a pseudo-instruction.
POP_JUMP_IF_NONE
Changed in version 3.12: This is no longer a pseudo-instruction.
LOAD_FAST_CHECK
LOAD_FAST_AND_CLEAR
LOAD_FROM_DICT_OR_DEREF
CALL_INTRINSIC_1
CALL_INTRINSIC_2
SETUP_CLEANUP
JUMP
JUMP_NO_INTERRUPT
The text was updated successfully, but these errors were encountered: