Skip to content

Commit d0d63b4

Browse files
authored
The oldest CAPI version we support right now is 3.7 (#15839)
Looks like `capi_version < 3.7` is not supported, so I changed the lowest version to be `3.7`. Based on the discord discussion.
1 parent eab5b50 commit d0d63b4

File tree

4 files changed

+6
-16
lines changed

4 files changed

+6
-16
lines changed

mypyc/codegen/emitclass.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
generate_richcompare_wrapper,
1919
generate_set_del_item_wrapper,
2020
)
21-
from mypyc.common import BITMAP_BITS, BITMAP_TYPE, NATIVE_PREFIX, PREFIX, REG_PREFIX, use_fastcall
21+
from mypyc.common import BITMAP_BITS, BITMAP_TYPE, NATIVE_PREFIX, PREFIX, REG_PREFIX
2222
from mypyc.ir.class_ir import ClassIR, VTableEntries
2323
from mypyc.ir.func_ir import FUNC_CLASSMETHOD, FUNC_STATICMETHOD, FuncDecl, FuncIR
2424
from mypyc.ir.rtypes import RTuple, RType, object_rprimitive
@@ -794,11 +794,7 @@ def generate_methods_table(cl: ClassIR, name: str, emitter: Emitter) -> None:
794794
continue
795795
emitter.emit_line(f'{{"{fn.name}",')
796796
emitter.emit_line(f" (PyCFunction){PREFIX}{fn.cname(emitter.names)},")
797-
if use_fastcall(emitter.capi_version):
798-
flags = ["METH_FASTCALL"]
799-
else:
800-
flags = ["METH_VARARGS"]
801-
flags.append("METH_KEYWORDS")
797+
flags = ["METH_FASTCALL", "METH_KEYWORDS"]
802798
if fn.decl.kind == FUNC_STATICMETHOD:
803799
flags.append("METH_STATIC")
804800
elif fn.decl.kind == FUNC_CLASSMETHOD:

mypyc/codegen/emitmodule.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
TOP_LEVEL_NAME,
4444
shared_lib_name,
4545
short_id_from_name,
46-
use_fastcall,
4746
use_vectorcall,
4847
)
4948
from mypyc.errors import Errors
@@ -1107,8 +1106,8 @@ def is_fastcall_supported(fn: FuncIR, capi_version: tuple[int, int]) -> bool:
11071106
# We can use vectorcalls (PEP 590) when supported
11081107
return use_vectorcall(capi_version)
11091108
# TODO: Support fastcall for __init__.
1110-
return use_fastcall(capi_version) and fn.name != "__init__"
1111-
return use_fastcall(capi_version)
1109+
return fn.name != "__init__"
1110+
return True
11121111

11131112

11141113
def collect_literals(fn: FuncIR, literals: Literals) -> None:

mypyc/common.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,6 @@ def short_name(name: str) -> str:
9898
return name
9999

100100

101-
def use_fastcall(capi_version: tuple[int, int]) -> bool:
102-
# We can use METH_FASTCALL for faster wrapper functions on Python 3.7+.
103-
return capi_version >= (3, 7)
104-
105-
106101
def use_vectorcall(capi_version: tuple[int, int]) -> bool:
107102
# We can use vectorcalls to make calls on Python 3.8+ (PEP 590).
108103
return capi_version >= (3, 8)

mypyc/test/testutil.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def build_ir_for_single_file2(
102102

103103
# By default generate IR compatible with the earliest supported Python C API.
104104
# If a test needs more recent API features, this should be overridden.
105-
compiler_options = compiler_options or CompilerOptions(capi_version=(3, 5))
105+
compiler_options = compiler_options or CompilerOptions(capi_version=(3, 7))
106106
options = Options()
107107
options.show_traceback = True
108108
options.hide_error_codes = True
@@ -272,7 +272,7 @@ def infer_ir_build_options_from_test_name(name: str) -> CompilerOptions | None:
272272
return None
273273
if "_32bit" in name and not IS_32_BIT_PLATFORM:
274274
return None
275-
options = CompilerOptions(strip_asserts="StripAssert" in name, capi_version=(3, 5))
275+
options = CompilerOptions(strip_asserts="StripAssert" in name, capi_version=(3, 7))
276276
# A suffix like _python3.8 is used to set the target C API version.
277277
m = re.search(r"_python([3-9]+)_([0-9]+)(_|\b)", name)
278278
if m:

0 commit comments

Comments
 (0)