Skip to content

Commit

Permalink
Add 3.13 support
Browse files Browse the repository at this point in the history
  • Loading branch information
brandtbucher committed Mar 27, 2024
1 parent dee5c78 commit 53f65fd
Show file tree
Hide file tree
Showing 25 changed files with 622 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ["3.11-dev", "3.12-dev"]
python: ["3.11-dev", "3.12-dev", "3.13-dev"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
6 changes: 3 additions & 3 deletions requirements-pre.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pip==23.2.1
setuptools==68.0.0
wheel==0.41.0
pip==24.0
setuptools==69.2.0
wheel==0.43.0
12 changes: 6 additions & 6 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
--requirement requirements-pre.txt
black==23.7.0
mypy==1.4.1
pylint==2.17.5
pytest==7.4.0
pytest-cov==4.1.0
black==24.3.0
mypy==1.9.0
pylint==3.1.0
pytest==8.1.1
pytest-cov==5.0.0
pytest-forked==1.6.0
pytest-randomly==3.13.0
pytest-randomly==3.15.0
93 changes: 54 additions & 39 deletions specialist.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Visualize CPython 3.11's specializing, adaptive interpreter."""

import pathlib
import sys
import types
Expand Down Expand Up @@ -48,49 +49,63 @@ def _audit_imports(event: str, args: "typing.Sequence[object]") -> None:
_RE_WHITESPACE = re.compile(r"(\s*\n\s*)")
_FIRST_POSTION = (1, 0)
_LAST_POSITION = (sys.maxsize, 0)
_CACHE_FORMAT = frozenset(opcode._cache_format) # type: ignore [attr-defined] # pylint: disable = protected-access
_SPECIALIZED_INSTRUCTIONS = frozenset(opcode._specialized_instructions) # type: ignore [attr-defined] # pylint: disable = protected-access
if sys.version_info < (3, 13): # pragma: no cover
_CACHE_FORMAT = frozenset(opcode._cache_format) # type: ignore [attr-defined] # pylint: disable = protected-access
else: # pragma: no cover
_CACHE_FORMAT = frozenset(opcode._cache_format) - { # type: ignore [attr-defined] # pylint: disable = protected-access
"JUMP_BACKWARD",
"POP_JUMP_IF_FALSE",
"POP_JUMP_IF_NONE",
"POP_JUMP_IF_NOT_NONE",
"POP_JUMP_IF_TRUE",
}
if sys.version_info < (3, 13): # pragma: no cover
_SPECIALIZED_INSTRUCTIONS = frozenset(opcode._specialized_instructions) # type: ignore [attr-defined] # pylint: disable = no-member, protected-access
else: # pragma: no cover
_SPECIALIZED_INSTRUCTIONS = frozenset(opcode._specialized_opmap) - {"RESUME_CHECK"} # type: ignore [attr-defined] # pylint: disable = no-member, protected-access
if sys.version_info < (3, 12): # pragma: no cover
_SUPERDUPERINSTRUCTIONS = frozenset({"PRECALL_NO_KW_LIST_APPEND"})
_SUPERINSTRUCTIONS = _SUPERDUPERINSTRUCTIONS | frozenset(
{
"BINARY_OP_INPLACE_ADD_UNICODE",
"COMPARE_OP_FLOAT_JUMP",
"COMPARE_OP_INT_JUMP",
"COMPARE_OP_STR_JUMP",
"LOAD_CONST__LOAD_FAST",
"LOAD_FAST__LOAD_CONST",
"LOAD_FAST__LOAD_FAST",
"PRECALL_BUILTIN_CLASS",
"PRECALL_BUILTIN_FAST_WITH_KEYWORDS",
"PRECALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS",
"PRECALL_NO_KW_BUILTIN_FAST",
"PRECALL_NO_KW_BUILTIN_O",
"PRECALL_NO_KW_ISINSTANCE",
"PRECALL_NO_KW_LEN",
"PRECALL_NO_KW_METHOD_DESCRIPTOR_FAST",
"PRECALL_NO_KW_METHOD_DESCRIPTOR_NOARGS",
"PRECALL_NO_KW_METHOD_DESCRIPTOR_O",
"PRECALL_NO_KW_STR_1",
"PRECALL_NO_KW_TUPLE_1",
"PRECALL_NO_KW_TYPE_1",
"STORE_FAST__LOAD_FAST",
"STORE_FAST__STORE_FAST",
}
)
_SUPERINSTRUCTIONS = _SUPERDUPERINSTRUCTIONS | {
"BINARY_OP_INPLACE_ADD_UNICODE",
"COMPARE_OP_FLOAT_JUMP",
"COMPARE_OP_INT_JUMP",
"COMPARE_OP_STR_JUMP",
"LOAD_CONST__LOAD_FAST",
"LOAD_FAST__LOAD_CONST",
"LOAD_FAST__LOAD_FAST",
"PRECALL_BUILTIN_CLASS",
"PRECALL_BUILTIN_FAST_WITH_KEYWORDS",
"PRECALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS",
"PRECALL_NO_KW_BUILTIN_FAST",
"PRECALL_NO_KW_BUILTIN_O",
"PRECALL_NO_KW_ISINSTANCE",
"PRECALL_NO_KW_LEN",
"PRECALL_NO_KW_METHOD_DESCRIPTOR_FAST",
"PRECALL_NO_KW_METHOD_DESCRIPTOR_NOARGS",
"PRECALL_NO_KW_METHOD_DESCRIPTOR_O",
"PRECALL_NO_KW_STR_1",
"PRECALL_NO_KW_TUPLE_1",
"PRECALL_NO_KW_TYPE_1",
"STORE_FAST__LOAD_FAST",
"STORE_FAST__STORE_FAST",
}
elif sys.version_info < (3, 13): # pragma: no cover
_SUPERDUPERINSTRUCTIONS: frozenset[str] = frozenset()
_SUPERINSTRUCTIONS = _SUPERDUPERINSTRUCTIONS | {
"BINARY_OP_INPLACE_ADD_UNICODE",
"CALL_NO_KW_LIST_APPEND",
"LOAD_CONST__LOAD_FAST",
"LOAD_FAST__LOAD_CONST",
"LOAD_FAST__LOAD_FAST",
"STORE_FAST__LOAD_FAST",
"STORE_FAST__STORE_FAST",
}
else: # pragma: no cover
_SUPERDUPERINSTRUCTIONS: frozenset[str] = frozenset()
_SUPERINSTRUCTIONS = _SUPERDUPERINSTRUCTIONS | frozenset(
{
"BINARY_OP_INPLACE_ADD_UNICODE",
"CALL_NO_KW_LIST_APPEND",
"LOAD_CONST__LOAD_FAST",
"LOAD_FAST__LOAD_CONST",
"LOAD_FAST__LOAD_FAST",
"STORE_FAST__LOAD_FAST",
"STORE_FAST__STORE_FAST",
}
)
_SUPERINSTRUCTIONS = _SUPERDUPERINSTRUCTIONS | {
"BINARY_OP_INPLACE_ADD_UNICODE",
"CALL_LIST_APPEND",
}
_PURELIB = pathlib.Path(sysconfig.get_path("purelib")).resolve()
assert _PURELIB.is_dir(), _PURELIB
_STDLIB = pathlib.Path(sysconfig.get_path("stdlib")).resolve()
Expand Down
14 changes: 14 additions & 0 deletions test-data/output-blue/output-0-3-13.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions test-data/output-blue/output-1-3-13.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions test-data/output-blue/output-2-3-13.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions test-data/output-blue/output-3-3-13.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 53f65fd

Please sign in to comment.