diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /contrib/tools/cython/Cython/Utility/Builtins.c | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/tools/cython/Cython/Utility/Builtins.c')
-rw-r--r-- | contrib/tools/cython/Cython/Utility/Builtins.c | 648 |
1 files changed, 324 insertions, 324 deletions
diff --git a/contrib/tools/cython/Cython/Utility/Builtins.c b/contrib/tools/cython/Cython/Utility/Builtins.c index 1ffb3bcebd..e21a5583ac 100644 --- a/contrib/tools/cython/Cython/Utility/Builtins.c +++ b/contrib/tools/cython/Cython/Utility/Builtins.c @@ -1,180 +1,180 @@ -/* - * Special implementations of built-in functions and methods. - * - * Optional optimisations for builtins are in Optimize.c. - * - * General object operations and protocols are in ObjectHandling.c. - */ - -//////////////////// Globals.proto //////////////////// - -static PyObject* __Pyx_Globals(void); /*proto*/ - -//////////////////// Globals //////////////////// -//@substitute: naming -//@requires: ObjectHandling.c::GetAttr - -// This is a stub implementation until we have something more complete. -// Currently, we only handle the most common case of a read-only dict -// of Python names. Supporting cdef names in the module and write -// access requires a rewrite as a dedicated class. - -static PyObject* __Pyx_Globals(void) { - Py_ssize_t i; - PyObject *names; - PyObject *globals = $moddict_cname; - Py_INCREF(globals); - names = PyObject_Dir($module_cname); - if (!names) - goto bad; - for (i = PyList_GET_SIZE(names)-1; i >= 0; i--) { -#if CYTHON_COMPILING_IN_PYPY +/* + * Special implementations of built-in functions and methods. + * + * Optional optimisations for builtins are in Optimize.c. + * + * General object operations and protocols are in ObjectHandling.c. + */ + +//////////////////// Globals.proto //////////////////// + +static PyObject* __Pyx_Globals(void); /*proto*/ + +//////////////////// Globals //////////////////// +//@substitute: naming +//@requires: ObjectHandling.c::GetAttr + +// This is a stub implementation until we have something more complete. +// Currently, we only handle the most common case of a read-only dict +// of Python names. Supporting cdef names in the module and write +// access requires a rewrite as a dedicated class. + +static PyObject* __Pyx_Globals(void) { + Py_ssize_t i; + PyObject *names; + PyObject *globals = $moddict_cname; + Py_INCREF(globals); + names = PyObject_Dir($module_cname); + if (!names) + goto bad; + for (i = PyList_GET_SIZE(names)-1; i >= 0; i--) { +#if CYTHON_COMPILING_IN_PYPY PyObject* name = PySequence_ITEM(names, i); - if (!name) - goto bad; -#else - PyObject* name = PyList_GET_ITEM(names, i); -#endif - if (!PyDict_Contains(globals, name)) { - PyObject* value = __Pyx_GetAttr($module_cname, name); - if (!value) { -#if CYTHON_COMPILING_IN_PYPY - Py_DECREF(name); -#endif - goto bad; - } - if (PyDict_SetItem(globals, name, value) < 0) { -#if CYTHON_COMPILING_IN_PYPY - Py_DECREF(name); -#endif - Py_DECREF(value); - goto bad; - } - } -#if CYTHON_COMPILING_IN_PYPY - Py_DECREF(name); -#endif - } - Py_DECREF(names); - return globals; -bad: - Py_XDECREF(names); - Py_XDECREF(globals); - return NULL; -} - -//////////////////// PyExecGlobals.proto //////////////////// - -static PyObject* __Pyx_PyExecGlobals(PyObject*); - -//////////////////// PyExecGlobals //////////////////// -//@requires: Globals -//@requires: PyExec - -static PyObject* __Pyx_PyExecGlobals(PyObject* code) { - PyObject* result; - PyObject* globals = __Pyx_Globals(); - if (unlikely(!globals)) - return NULL; - result = __Pyx_PyExec2(code, globals); - Py_DECREF(globals); - return result; -} - -//////////////////// PyExec.proto //////////////////// - -static PyObject* __Pyx_PyExec3(PyObject*, PyObject*, PyObject*); -static CYTHON_INLINE PyObject* __Pyx_PyExec2(PyObject*, PyObject*); - -//////////////////// PyExec //////////////////// -//@substitute: naming - -static CYTHON_INLINE PyObject* __Pyx_PyExec2(PyObject* o, PyObject* globals) { - return __Pyx_PyExec3(o, globals, NULL); -} - -static PyObject* __Pyx_PyExec3(PyObject* o, PyObject* globals, PyObject* locals) { - PyObject* result; - PyObject* s = 0; - char *code = 0; - - if (!globals || globals == Py_None) { - globals = $moddict_cname; - } else if (!PyDict_Check(globals)) { - PyErr_Format(PyExc_TypeError, "exec() arg 2 must be a dict, not %.200s", - Py_TYPE(globals)->tp_name); - goto bad; - } - if (!locals || locals == Py_None) { - locals = globals; - } - + if (!name) + goto bad; +#else + PyObject* name = PyList_GET_ITEM(names, i); +#endif + if (!PyDict_Contains(globals, name)) { + PyObject* value = __Pyx_GetAttr($module_cname, name); + if (!value) { +#if CYTHON_COMPILING_IN_PYPY + Py_DECREF(name); +#endif + goto bad; + } + if (PyDict_SetItem(globals, name, value) < 0) { +#if CYTHON_COMPILING_IN_PYPY + Py_DECREF(name); +#endif + Py_DECREF(value); + goto bad; + } + } +#if CYTHON_COMPILING_IN_PYPY + Py_DECREF(name); +#endif + } + Py_DECREF(names); + return globals; +bad: + Py_XDECREF(names); + Py_XDECREF(globals); + return NULL; +} + +//////////////////// PyExecGlobals.proto //////////////////// + +static PyObject* __Pyx_PyExecGlobals(PyObject*); + +//////////////////// PyExecGlobals //////////////////// +//@requires: Globals +//@requires: PyExec + +static PyObject* __Pyx_PyExecGlobals(PyObject* code) { + PyObject* result; + PyObject* globals = __Pyx_Globals(); + if (unlikely(!globals)) + return NULL; + result = __Pyx_PyExec2(code, globals); + Py_DECREF(globals); + return result; +} + +//////////////////// PyExec.proto //////////////////// + +static PyObject* __Pyx_PyExec3(PyObject*, PyObject*, PyObject*); +static CYTHON_INLINE PyObject* __Pyx_PyExec2(PyObject*, PyObject*); + +//////////////////// PyExec //////////////////// +//@substitute: naming + +static CYTHON_INLINE PyObject* __Pyx_PyExec2(PyObject* o, PyObject* globals) { + return __Pyx_PyExec3(o, globals, NULL); +} + +static PyObject* __Pyx_PyExec3(PyObject* o, PyObject* globals, PyObject* locals) { + PyObject* result; + PyObject* s = 0; + char *code = 0; + + if (!globals || globals == Py_None) { + globals = $moddict_cname; + } else if (!PyDict_Check(globals)) { + PyErr_Format(PyExc_TypeError, "exec() arg 2 must be a dict, not %.200s", + Py_TYPE(globals)->tp_name); + goto bad; + } + if (!locals || locals == Py_None) { + locals = globals; + } + if (__Pyx_PyDict_GetItemStr(globals, PYIDENT("__builtins__")) == NULL) { - if (PyDict_SetItem(globals, PYIDENT("__builtins__"), PyEval_GetBuiltins()) < 0) - goto bad; - } - - if (PyCode_Check(o)) { + if (PyDict_SetItem(globals, PYIDENT("__builtins__"), PyEval_GetBuiltins()) < 0) + goto bad; + } + + if (PyCode_Check(o)) { if (__Pyx_PyCode_HasFreeVars((PyCodeObject *)o)) { - PyErr_SetString(PyExc_TypeError, - "code object passed to exec() may not contain free variables"); - goto bad; - } + PyErr_SetString(PyExc_TypeError, + "code object passed to exec() may not contain free variables"); + goto bad; + } #if CYTHON_COMPILING_IN_PYPY || PY_VERSION_HEX < 0x030200B1 - result = PyEval_EvalCode((PyCodeObject *)o, globals, locals); - #else - result = PyEval_EvalCode(o, globals, locals); - #endif - } else { - PyCompilerFlags cf; - cf.cf_flags = 0; + result = PyEval_EvalCode((PyCodeObject *)o, globals, locals); + #else + result = PyEval_EvalCode(o, globals, locals); + #endif + } else { + PyCompilerFlags cf; + cf.cf_flags = 0; #if PY_VERSION_HEX >= 0x030800A3 cf.cf_feature_version = PY_MINOR_VERSION; #endif - if (PyUnicode_Check(o)) { - cf.cf_flags = PyCF_SOURCE_IS_UTF8; - s = PyUnicode_AsUTF8String(o); - if (!s) goto bad; - o = s; - #if PY_MAJOR_VERSION >= 3 - } else if (!PyBytes_Check(o)) { - #else - } else if (!PyString_Check(o)) { - #endif - PyErr_Format(PyExc_TypeError, - "exec: arg 1 must be string, bytes or code object, got %.200s", - Py_TYPE(o)->tp_name); - goto bad; - } - #if PY_MAJOR_VERSION >= 3 - code = PyBytes_AS_STRING(o); - #else - code = PyString_AS_STRING(o); - #endif - if (PyEval_MergeCompilerFlags(&cf)) { - result = PyRun_StringFlags(code, Py_file_input, globals, locals, &cf); - } else { - result = PyRun_String(code, Py_file_input, globals, locals); - } - Py_XDECREF(s); - } - - return result; -bad: - Py_XDECREF(s); - return 0; -} - -//////////////////// GetAttr3.proto //////////////////// - -static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *); /*proto*/ - -//////////////////// GetAttr3 //////////////////// -//@requires: ObjectHandling.c::GetAttr + if (PyUnicode_Check(o)) { + cf.cf_flags = PyCF_SOURCE_IS_UTF8; + s = PyUnicode_AsUTF8String(o); + if (!s) goto bad; + o = s; + #if PY_MAJOR_VERSION >= 3 + } else if (!PyBytes_Check(o)) { + #else + } else if (!PyString_Check(o)) { + #endif + PyErr_Format(PyExc_TypeError, + "exec: arg 1 must be string, bytes or code object, got %.200s", + Py_TYPE(o)->tp_name); + goto bad; + } + #if PY_MAJOR_VERSION >= 3 + code = PyBytes_AS_STRING(o); + #else + code = PyString_AS_STRING(o); + #endif + if (PyEval_MergeCompilerFlags(&cf)) { + result = PyRun_StringFlags(code, Py_file_input, globals, locals, &cf); + } else { + result = PyRun_String(code, Py_file_input, globals, locals); + } + Py_XDECREF(s); + } + + return result; +bad: + Py_XDECREF(s); + return 0; +} + +//////////////////// GetAttr3.proto //////////////////// + +static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *); /*proto*/ + +//////////////////// GetAttr3 //////////////////// +//@requires: ObjectHandling.c::GetAttr //@requires: Exceptions.c::PyThreadStateGet //@requires: Exceptions.c::PyErrFetchRestore //@requires: Exceptions.c::PyErrExceptionMatches - + static PyObject *__Pyx_GetAttr3Default(PyObject *d) { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign @@ -185,8 +185,8 @@ static PyObject *__Pyx_GetAttr3Default(PyObject *d) { return d; } -static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) { - PyObject *r = __Pyx_GetAttr(o, n); +static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) { + PyObject *r = __Pyx_GetAttr(o, n); return (likely(r)) ? r : __Pyx_GetAttr3Default(d); } @@ -205,37 +205,37 @@ static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) { return -1; } r = __Pyx_GetAttr(o, n); - if (unlikely(!r)) { - PyErr_Clear(); + if (unlikely(!r)) { + PyErr_Clear(); return 0; } else { Py_DECREF(r); return 1; - } -} - -//////////////////// Intern.proto //////////////////// - -static PyObject* __Pyx_Intern(PyObject* s); /* proto */ - -//////////////////// Intern //////////////////// - -static PyObject* __Pyx_Intern(PyObject* s) { - if (!(likely(PyString_CheckExact(s)))) { - PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(s)->tp_name); - return 0; - } - Py_INCREF(s); - #if PY_MAJOR_VERSION >= 3 - PyUnicode_InternInPlace(&s); - #else - PyString_InternInPlace(&s); - #endif - return s; -} - -//////////////////// abs_longlong.proto //////////////////// - + } +} + +//////////////////// Intern.proto //////////////////// + +static PyObject* __Pyx_Intern(PyObject* s); /* proto */ + +//////////////////// Intern //////////////////// + +static PyObject* __Pyx_Intern(PyObject* s) { + if (!(likely(PyString_CheckExact(s)))) { + PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(s)->tp_name); + return 0; + } + Py_INCREF(s); + #if PY_MAJOR_VERSION >= 3 + PyUnicode_InternInPlace(&s); + #else + PyString_InternInPlace(&s); + #endif + return s; +} + +//////////////////// abs_longlong.proto //////////////////// + static CYTHON_INLINE PY_LONG_LONG __Pyx_abs_longlong(PY_LONG_LONG x) { #if defined (__cplusplus) && __cplusplus >= 201103L return std::abs(x); @@ -248,13 +248,13 @@ static CYTHON_INLINE PY_LONG_LONG __Pyx_abs_longlong(PY_LONG_LONG x) { #elif defined (__GNUC__) // gcc or clang on 64 bit windows. return __builtin_llabs(x); -#else +#else if (sizeof(PY_LONG_LONG) <= sizeof(Py_ssize_t)) return __Pyx_sst_abs(x); return (x<0) ? -x : x; -#endif -} - +#endif +} + //////////////////// py_abs.proto //////////////////// @@ -294,10 +294,10 @@ static PyObject *__Pyx_PyLong_AbsNeg(PyObject *n) { #endif -//////////////////// pow2.proto //////////////////// - -#define __Pyx_PyNumber_Power2(a, b) PyNumber_Power(a, b, Py_None) - +//////////////////// pow2.proto //////////////////// + +#define __Pyx_PyNumber_Power2(a, b) PyNumber_Power(a, b, Py_None) + //////////////////// object_ord.proto //////////////////// //@requires: TypeConversion.c::UnicodeAsUCS4 @@ -342,143 +342,143 @@ static long __Pyx__PyObject_Ord(PyObject* c) { } -//////////////////// py_dict_keys.proto //////////////////// - -static CYTHON_INLINE PyObject* __Pyx_PyDict_Keys(PyObject* d); /*proto*/ - -//////////////////// py_dict_keys //////////////////// - -static CYTHON_INLINE PyObject* __Pyx_PyDict_Keys(PyObject* d) { - if (PY_MAJOR_VERSION >= 3) +//////////////////// py_dict_keys.proto //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_Keys(PyObject* d); /*proto*/ + +//////////////////// py_dict_keys //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_Keys(PyObject* d) { + if (PY_MAJOR_VERSION >= 3) return CALL_UNBOUND_METHOD(PyDict_Type, "keys", d); - else - return PyDict_Keys(d); -} - -//////////////////// py_dict_values.proto //////////////////// - -static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d); /*proto*/ - -//////////////////// py_dict_values //////////////////// - -static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d) { - if (PY_MAJOR_VERSION >= 3) + else + return PyDict_Keys(d); +} + +//////////////////// py_dict_values.proto //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d); /*proto*/ + +//////////////////// py_dict_values //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d) { + if (PY_MAJOR_VERSION >= 3) return CALL_UNBOUND_METHOD(PyDict_Type, "values", d); - else - return PyDict_Values(d); -} - -//////////////////// py_dict_items.proto //////////////////// - -static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d); /*proto*/ - -//////////////////// py_dict_items //////////////////// - -static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) { - if (PY_MAJOR_VERSION >= 3) + else + return PyDict_Values(d); +} + +//////////////////// py_dict_items.proto //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d); /*proto*/ + +//////////////////// py_dict_items //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) { + if (PY_MAJOR_VERSION >= 3) return CALL_UNBOUND_METHOD(PyDict_Type, "items", d); - else - return PyDict_Items(d); -} - -//////////////////// py_dict_iterkeys.proto //////////////////// - -static CYTHON_INLINE PyObject* __Pyx_PyDict_IterKeys(PyObject* d); /*proto*/ - -//////////////////// py_dict_iterkeys //////////////////// - -static CYTHON_INLINE PyObject* __Pyx_PyDict_IterKeys(PyObject* d) { + else + return PyDict_Items(d); +} + +//////////////////// py_dict_iterkeys.proto //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_IterKeys(PyObject* d); /*proto*/ + +//////////////////// py_dict_iterkeys //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_IterKeys(PyObject* d) { if (PY_MAJOR_VERSION >= 3) return CALL_UNBOUND_METHOD(PyDict_Type, "keys", d); else return CALL_UNBOUND_METHOD(PyDict_Type, "iterkeys", d); -} - -//////////////////// py_dict_itervalues.proto //////////////////// - -static CYTHON_INLINE PyObject* __Pyx_PyDict_IterValues(PyObject* d); /*proto*/ - -//////////////////// py_dict_itervalues //////////////////// - -static CYTHON_INLINE PyObject* __Pyx_PyDict_IterValues(PyObject* d) { +} + +//////////////////// py_dict_itervalues.proto //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_IterValues(PyObject* d); /*proto*/ + +//////////////////// py_dict_itervalues //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_IterValues(PyObject* d) { if (PY_MAJOR_VERSION >= 3) return CALL_UNBOUND_METHOD(PyDict_Type, "values", d); else return CALL_UNBOUND_METHOD(PyDict_Type, "itervalues", d); -} - -//////////////////// py_dict_iteritems.proto //////////////////// - -static CYTHON_INLINE PyObject* __Pyx_PyDict_IterItems(PyObject* d); /*proto*/ - -//////////////////// py_dict_iteritems //////////////////// - -static CYTHON_INLINE PyObject* __Pyx_PyDict_IterItems(PyObject* d) { +} + +//////////////////// py_dict_iteritems.proto //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_IterItems(PyObject* d); /*proto*/ + +//////////////////// py_dict_iteritems //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_IterItems(PyObject* d) { if (PY_MAJOR_VERSION >= 3) return CALL_UNBOUND_METHOD(PyDict_Type, "items", d); else return CALL_UNBOUND_METHOD(PyDict_Type, "iteritems", d); -} - -//////////////////// py_dict_viewkeys.proto //////////////////// - -#if PY_VERSION_HEX < 0x02070000 -#error This module uses dict views, which require Python 2.7 or later -#endif -static CYTHON_INLINE PyObject* __Pyx_PyDict_ViewKeys(PyObject* d); /*proto*/ - -//////////////////// py_dict_viewkeys //////////////////// - -static CYTHON_INLINE PyObject* __Pyx_PyDict_ViewKeys(PyObject* d) { +} + +//////////////////// py_dict_viewkeys.proto //////////////////// + +#if PY_VERSION_HEX < 0x02070000 +#error This module uses dict views, which require Python 2.7 or later +#endif +static CYTHON_INLINE PyObject* __Pyx_PyDict_ViewKeys(PyObject* d); /*proto*/ + +//////////////////// py_dict_viewkeys //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_ViewKeys(PyObject* d) { if (PY_MAJOR_VERSION >= 3) return CALL_UNBOUND_METHOD(PyDict_Type, "keys", d); else return CALL_UNBOUND_METHOD(PyDict_Type, "viewkeys", d); -} - -//////////////////// py_dict_viewvalues.proto //////////////////// - -#if PY_VERSION_HEX < 0x02070000 -#error This module uses dict views, which require Python 2.7 or later -#endif -static CYTHON_INLINE PyObject* __Pyx_PyDict_ViewValues(PyObject* d); /*proto*/ - -//////////////////// py_dict_viewvalues //////////////////// - -static CYTHON_INLINE PyObject* __Pyx_PyDict_ViewValues(PyObject* d) { +} + +//////////////////// py_dict_viewvalues.proto //////////////////// + +#if PY_VERSION_HEX < 0x02070000 +#error This module uses dict views, which require Python 2.7 or later +#endif +static CYTHON_INLINE PyObject* __Pyx_PyDict_ViewValues(PyObject* d); /*proto*/ + +//////////////////// py_dict_viewvalues //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_ViewValues(PyObject* d) { if (PY_MAJOR_VERSION >= 3) return CALL_UNBOUND_METHOD(PyDict_Type, "values", d); else return CALL_UNBOUND_METHOD(PyDict_Type, "viewvalues", d); -} - -//////////////////// py_dict_viewitems.proto //////////////////// - -#if PY_VERSION_HEX < 0x02070000 -#error This module uses dict views, which require Python 2.7 or later -#endif -static CYTHON_INLINE PyObject* __Pyx_PyDict_ViewItems(PyObject* d); /*proto*/ - -//////////////////// py_dict_viewitems //////////////////// - -static CYTHON_INLINE PyObject* __Pyx_PyDict_ViewItems(PyObject* d) { +} + +//////////////////// py_dict_viewitems.proto //////////////////// + +#if PY_VERSION_HEX < 0x02070000 +#error This module uses dict views, which require Python 2.7 or later +#endif +static CYTHON_INLINE PyObject* __Pyx_PyDict_ViewItems(PyObject* d); /*proto*/ + +//////////////////// py_dict_viewitems //////////////////// + +static CYTHON_INLINE PyObject* __Pyx_PyDict_ViewItems(PyObject* d) { if (PY_MAJOR_VERSION >= 3) return CALL_UNBOUND_METHOD(PyDict_Type, "items", d); else return CALL_UNBOUND_METHOD(PyDict_Type, "viewitems", d); -} - +} + -//////////////////// pyfrozenset_new.proto //////////////////// +//////////////////// pyfrozenset_new.proto //////////////////// static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it); //////////////////// pyfrozenset_new //////////////////// -//@substitute: naming - -static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it) { - if (it) { - PyObject* result; +//@substitute: naming + +static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it) { + if (it) { + PyObject* result; #if CYTHON_COMPILING_IN_PYPY // PyPy currently lacks PyFrozenSet_CheckExact() and PyFrozenSet_New() PyObject* args; @@ -489,24 +489,24 @@ static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it) { Py_DECREF(args); return result; #else - if (PyFrozenSet_CheckExact(it)) { - Py_INCREF(it); - return it; - } - result = PyFrozenSet_New(it); - if (unlikely(!result)) - return NULL; + if (PyFrozenSet_CheckExact(it)) { + Py_INCREF(it); + return it; + } + result = PyFrozenSet_New(it); + if (unlikely(!result)) + return NULL; if ((PY_VERSION_HEX >= 0x031000A1) || likely(PySet_GET_SIZE(result))) - return result; + return result; // empty frozenset is a singleton (on Python <3.10) - // seems wasteful, but CPython does the same - Py_DECREF(result); + // seems wasteful, but CPython does the same + Py_DECREF(result); #endif - } + } #if CYTHON_USE_TYPE_SLOTS - return PyFrozenSet_Type.tp_new(&PyFrozenSet_Type, $empty_tuple, NULL); + return PyFrozenSet_Type.tp_new(&PyFrozenSet_Type, $empty_tuple, NULL); #else - return PyObject_Call((PyObject*)&PyFrozenSet_Type, $empty_tuple, NULL); + return PyObject_Call((PyObject*)&PyFrozenSet_Type, $empty_tuple, NULL); #endif } @@ -534,9 +534,9 @@ static CYTHON_INLINE int __Pyx_PySet_Update(PyObject* set, PyObject* it) { // unusual result, fall through to set.update() call below Py_DECREF(retval); } - #endif + #endif retval = CALL_UNBOUND_METHOD(PySet_Type, "update", set, it); if (unlikely(!retval)) return -1; Py_DECREF(retval); return 0; -} +} |