summaryrefslogtreecommitdiff
path: root/Cython/Compiler/PyrexTypes.py
diff options
context:
space:
mode:
authorscoder <stefan_ml@behnel.de>2023-05-15 22:07:30 +0200
committerGitHub <noreply@github.com>2023-05-15 22:07:30 +0200
commitdec61cdd222ded6d5f96a635d9c4b0dddcbc4e78 (patch)
treee6659d13144cf489abdaaf7a23106d8f46f5bf6c /Cython/Compiler/PyrexTypes.py
parent580ceee71fd890b86678ec3c41b6a2b73b18440f (diff)
downloadcython-dec61cdd222ded6d5f96a635d9c4b0dddcbc4e78.tar.gz
Custom int128 conversion as a slow fallback (GH-5419)
* Use a custom (although slow) PyLong->cint128 conversion if "_PyLong_AsByteArray()" is missing (in PyPy/Limited API). * Avoid large integer conversion for enum types (where shift etc. don't work well).
Diffstat (limited to 'Cython/Compiler/PyrexTypes.py')
-rw-r--r--Cython/Compiler/PyrexTypes.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py
index 741f0af66..19d193dcf 100644
--- a/Cython/Compiler/PyrexTypes.py
+++ b/Cython/Compiler/PyrexTypes.py
@@ -532,8 +532,11 @@ class CTypedefType(BaseType):
self.from_py_function = "__Pyx_PyInt_As_" + self.specialization_name()
env.use_utility_code(TempitaUtilityCode.load_cached(
"CIntFromPy", "TypeConversion.c",
- context={"TYPE": self.empty_declaration_code(),
- "FROM_PY_FUNCTION": self.from_py_function}))
+ context={
+ "TYPE": self.empty_declaration_code(),
+ "FROM_PY_FUNCTION": self.from_py_function,
+ "IS_ENUM": base_type.is_enum,
+ }))
return True
elif base_type.is_float:
pass # XXX implement!
@@ -2043,8 +2046,11 @@ class CIntLike(object):
self.from_py_function = "__Pyx_PyInt_As_" + self.specialization_name()
env.use_utility_code(TempitaUtilityCode.load_cached(
"CIntFromPy", "TypeConversion.c",
- context={"TYPE": self.empty_declaration_code(),
- "FROM_PY_FUNCTION": self.from_py_function}))
+ context={
+ "TYPE": self.empty_declaration_code(),
+ "FROM_PY_FUNCTION": self.from_py_function,
+ "IS_ENUM": self.is_enum,
+ }))
return True
@staticmethod