diff options
Diffstat (limited to 'Objects')
| -rw-r--r-- | Objects/typeobject.c | 22 | ||||
| -rw-r--r-- | Objects/unicodeobject.c | 9 |
2 files changed, 26 insertions, 5 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 6ece741..f40dd10 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -7,6 +7,10 @@ #include <ctype.h> +/* Cached lookup of the copyreg module, for faster __reduce__ calls */ + +static PyObject *cached_copyreg_module = NULL; + /* Support type attribute cache */ /* The cache can keep references to the names alive for longer than @@ -69,6 +73,15 @@ PyType_ClearCache(void) } void +_PyType_Fini(void) +{ + PyType_ClearCache(); + /* Need to forget our obsolete instance of the copyreg module at + * interpreter shutdown (issue #17408). */ + Py_CLEAR(cached_copyreg_module); +} + +void PyType_Modified(PyTypeObject *type) { /* Invalidate any cached data for the specified type and all @@ -3339,19 +3352,18 @@ static PyObject * import_copyreg(void) { static PyObject *copyreg_str; - static PyObject *mod_copyreg = NULL; if (!copyreg_str) { copyreg_str = PyUnicode_InternFromString("copyreg"); if (copyreg_str == NULL) return NULL; } - if (!mod_copyreg) { - mod_copyreg = PyImport_Import(copyreg_str); + if (!cached_copyreg_module) { + cached_copyreg_module = PyImport_Import(copyreg_str); } - Py_XINCREF(mod_copyreg); - return mod_copyreg; + Py_XINCREF(cached_copyreg_module); + return cached_copyreg_module; } static PyObject * diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index c21e80c..8d6cda5 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -4661,6 +4661,14 @@ ascii_decode(const char *start, const char *end, Py_UCS1 *dest) const char *p = start; const char *aligned_end = (const char *) _Py_ALIGN_DOWN(end, SIZEOF_LONG); + /* + * Issue #17237: m68k is a bit different from most architectures in + * that objects do not use "natural alignment" - for example, int and + * long are only aligned at 2-byte boundaries. Therefore the assert() + * won't work; also, tests have shown that skipping the "optimised + * version" will even speed up m68k. + */ +#if !defined(__m68k__) #if SIZEOF_LONG <= SIZEOF_VOID_P assert(_Py_IS_ALIGNED(dest, SIZEOF_LONG)); if (_Py_IS_ALIGNED(p, SIZEOF_LONG)) { @@ -4686,6 +4694,7 @@ ascii_decode(const char *start, const char *end, Py_UCS1 *dest) return p - start; } #endif +#endif while (p < end) { /* Fast path, see in STRINGLIB(utf8_decode) in stringlib/codecs.h for an explanation. */ |
