Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions mypyc/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,10 +680,13 @@ def mypycify(
cflags.append("-DMYPYC_LOG_TRACE")
if experimental_features:
cflags.append("-DMYPYC_EXPERIMENTAL")
if opt_level == "0":
cflags.append("-UNDEBUG")
elif compiler.compiler_type == "msvc":
# msvc doesn't have levels, '/O2' is full and '/Od' is disable
if opt_level == "0":
opt_level = "d"
cflags.append("/UNDEBUG")
elif opt_level in ("1", "2", "3"):
opt_level = "2"
if debug_level == "0":
Expand Down
6 changes: 6 additions & 0 deletions mypyc/lib-rt/CPy.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,13 +331,19 @@ static inline bool CPyTagged_IsLe(CPyTagged left, CPyTagged right) {
static inline int64_t CPyLong_AsInt64(PyObject *o) {
if (likely(PyLong_Check(o))) {
PyLongObject *lobj = (PyLongObject *)o;
#if CPY_3_12_FEATURES
if (likely(PyUnstable_Long_IsCompact(lobj))) {
return PyUnstable_Long_CompactValue(lobj);
}
#else
Py_ssize_t size = Py_SIZE(lobj);
if (likely(size == 1)) {
// Fast path
return CPY_LONG_DIGIT(lobj, 0);
} else if (likely(size == 0)) {
return 0;
}
#endif
}
// Slow path
return CPyLong_AsInt64_(o);
Expand Down
4 changes: 4 additions & 0 deletions mypyc/lib-rt/static_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ mypyc_interned_str_struct mypyc_interned_str;

int
intern_strings(void) {
if (mypyc_interned_str.values != NULL) {
// Already interned.
return 0;
}
INTERN_STRING(__init_subclass__, "__init_subclass__");
INTERN_STRING(__mro_entries__, "__mro_entries__");
INTERN_STRING(__name__, "__name__");
Expand Down