Notice: While JavaScript is not essential for this website, your interaction with the content will be limited. Please turn JavaScript on for the full experience.
...const hash)(const void *, Py_ssize_t); const char *name; /* name of the hash algorithm and variant */ const int hash_bits; /* internal size of hash value */ const int seed_bits; /* size of seed input */ } PyHash_FuncDef; PyAPI_FUNC(PyHash_FuncDef*) PyHash_GetFuncDef(void); autoconf A new test is added to the configure script. The test sets HAVE_ALIGNED_REQUIRED, when it detects a platform, that requires aligned memory access for integers. Must current platforms such a...
...const Py_UCS1 *)(PyUnicode_DATA((unicode))))[(index)] : \ (PyUnicode_KIND((unicode)) == PyUnicode_2BYTE_KIND ? \ ((const Py_UCS2 *)(PyUnicode_DATA((unicode))))[(index)] : \ ((const Py_UCS4 *)(PyUnicode_DATA((unicode))))[(index)] \ ) \ )) Possible implementation as a static inlined function: static inline Py_UCS4 PyUnicode_READ_CHAR(PyObject *unicode, Py_ssize_t index) { assert(PyUnicode_Check(unicode)); assert(PyUnicode_IS_READY(unicode)); ...
...const pointer to the PyCCallDef structure used for this call. For example, we have the following signature: CCALL_DEFARG | CCALL_VARARGS: cc_func(const PyCCallDef *def, PyObject *self, PyObject *args) One exception is CCALL_DEFARG | CCALL_NOARGS: the unused argument is dropped, so the signature becomes CCALL_DEFARG | CCALL_NOARGS: cc_func(const PyCCallDef *def, PyObject *self) NOTE: unlike the existing METH_... flags, the CCALL_... constants do not necessarily represent single bits. So check...
...const char *name, PyObject *error) PyObject *PyCodec_LookupError(const char *name) and their Python counterparts: codecs.register_error(name, error) codecs.lookup_error(name) PyCodec_LookupError raises a LookupError if no callback function has been registered under this name. Similar to the encoding name registry there is no way of unregistering callback functions or iterating through the available functions. The callback functions will be used in the following way by the codecs: when the c...
...const PyPreConfig *preconfig) PyStatus Py_PreInitializeFromBytesArgs(const PyPreConfig *preconfig, int argc, char * const *argv) PyStatus Py_PreInitializeFromArgs(const PyPreConfig *preconfig, int argc, wchar_t * const * argv) The caller is responsible to handle exceptions (error or exit) using PyStatus_Exception() and Py_ExitStatusException(). For Python Configuration (PyPreConfig_InitPythonConfig()), if Python is initialized with command line arguments, the command line arguments must also be...
...const void **); typedef size_t (*acquirelockedwritebufferproc)(PyObject *, void **); typedef void (*releaselockedbufferproc)(PyObject *); typedef struct { getreadbufferproc bf_getreadbuffer; getwritebufferproc bf_getwritebuffer; getsegcountproc bf_getsegcount; getcharbufferproc bf_getcharbuffer; /* locked buffer interface functions */ acquirelockedreadbufferproc bf_acquirelockedreadbuffer; acquirelockedwritebufferproc bf...
...consts = ['Ni! Ni! Ni!' if isinstance(const, str) else const for const in code.co_consts] return types.CodeType(code.co_argcount, code.co_kwonlyargcount, code.co_nlocals, code.co_stacksize, code.co_flags, code.co_code, tuple(consts), code.co_names, ...
...const references, in order to prevent dangling pointers and references from causing crashes on the Python side. This limits the library's ability to export arbitrary C++ functions. Goal: Implementation of a mechanism by which references and pointers to internal elements of function and method arguments can be returned safely. This will include a mechanism by which any argument object can be kept alive during the lifetime of any other argument object, so that Wrapped...
...const char *ml_name; PyCFunction ml_meth; int ml_flags; const char *ml_doc; } PyMethodDef; Note that PyMethodDef is part of the Python Stable ABI and it is used by practically all extension modules, so we absolutely cannot change this structure. Argument Clinic is supported. __self__ always exists. In the cases where base_function.__self__ would raise AttributeError, instead None is returned. The type object is PyTypeObject PyCFunction_Type and we define PyCFunctionObject as ali...
...const *args: A vector of arguments size_t nargs: The number of arguments plus the optional flag PY_VECTORCALL_ARGUMENTS_OFFSET (see below) PyObject *kwnames: Either NULL or a tuple with the names of the keyword arguments This is implemented by the function pointer type: typedef PyObject *(*vectorcallfunc)(PyObject *callable, PyObject *const *args, size_t nargs, PyObject *kwnames); Changes to the PyTypeObject struct The unused slot printfunc tp_print is replaced with tp_vectorcall_offset. It h...
...const char *filename, int lineno, size_t size); /* allocate or resize a memory block */ void* (*realloc) (void *ctx, const char *filename, int lineno, void *ptr, size_t new_size); /* release a memory block */ void (*free) (void *ctx, const char *filename, int lineno, void *ptr); } PyMemAllocator; void* _PyMem_MallocTrace(const char *filename, int lineno, size_t size); /* the function is stil...
...const char *res; "s*": [str, bytes, bytearray, rw_buffer] -> Py_buffer &res; [...] "es#": str -> (const char *res_encoding, char **res, Py_ssize_t *res_length); [...] ##### Custom converters ##### path_converter: [str, bytes, int] -> path_t &res; OS_STAT_DIR_FD_CONVERTER: [int, None] -> int res; [converter_end]*/ Converters are specified by their name, Python input type(s) and C output type(s). Default converters must have quoted names, custom converters m...
...Constructors Python should provide a built-in constructor for Unicode strings which is available through __builtins__: u = unicode(encoded_string[,encoding=<default encoding>][,errors="strict"]) u = u'<unicode-escape encoded Python string>' u = ur'<raw-unicode-escape encoded Python string>' With the 'unicode-escape' encoding being defined as: all non-escape characters represent themselves as Unicode ordinal (e.g. 'a' -> U+0061). all existing defined Python escape sequen...
...Const = Annotated[T, my_annotations.CONST] Class C: def const_method(self: Const[List[int]]) -> int: ... Rejected ideas Some of the proposed ideas were rejected from this PEP because they would cause Annotated to not integrate cleanly with the other typing annotations: Annotated cannot infer the decorated type. You could imagine that Annotated[..., Immutable] could be used to mark a value as immutable while still inferring its type. Typing does not support using the inferred...
...const char *errors parameter is missing. There is no public alternative API. But user can use generic PyUnicode_AsEncodedString() instead. const char *errors, int byteorder parameters are missing. There is no direct replacement. But Py_UNICODE_TODECIMAL can be used instead. CPython uses _PyUnicode_TransformDecimalAndSpaceToASCII for converting from Unicode to numbers instead. Plan Remove these APIs in Python 3.11. They have been deprecated already. PyUnicode_Encode() PyUnicode_EncodeASCII() ...
...const PyRuntimeConfig *config ); PyInitError Py_InitializeRuntimeFromArgs( const PyRuntimeConfig *config, int argc, char **argv ); PyInitError Py_InitializeRuntimeFromWideArgs( const PyRuntimeConfig *config, int argc, wchar_t **argv ); If Py_IsInitializing() is false, the Py_InitializeRuntime functions will implicitly call the corresponding Py_PreInitialize function. The use_environment setting will be passed down, while other settings will be processed according to their defaults, as...
...constants; for example _ssl has a long list of calls in the form: PyModule_AddIntConstant(m, "SSL_ERROR_ZERO_RETURN", PY_SSL_ERROR_ZERO_RETURN); Converting this to a declarative list, similar to PyMethodDef, would reduce boilerplate, and provide free error-checking which is often missing. String constants and types can be handled similarly. (Note that non-default bases for types cannot be portably specified statically; this case would need a Py_mod_exec function that ru...
...const char *event, PyObject *args, void *userData); int PySys_AddAuditHook(hook_func hook, void *userData); # Raise an event with all auditing hooks int PySys_Audit(const char *event, PyObject *args); The new Python APIs for receiving and raising audit hooks are: # Add an auditing hook sys.addaudithook(hook: Callable[[str, tuple]]) # Raise an event with all auditing hooks sys.audit(str, *args) Hooks are added by calling PySys_AddAuditHook() from C at any time, inclu...
...const cthulhu = { H̹̙̦̮͉̩̗̗ͧ̇̏̊̾Eͨ͆͒̆ͮ̃͏̷̮̣̫̤̣Cͯ̂͐͏̨̛͔̦̟͈̻O̜͎͍͙͚̬̝̣̽ͮ͐͗̀ͤ̍̀͢M̴̡̲̭͍͇̼̟̯̦̉̒͠Ḛ̛̙̞̪̗ͥͤͩ̾͑̔͐ͅṮ̴̷̷̗̼͍̿̿̓̽͐H̙̙̔̄͜\u0042: 42 } is valid ECMAScript 2016 [2]Wikipedia article on string interpolation ( https://en.wikipedia.org/wiki/String_interpolation ) Copyright This document has been placed in the public domain. Source: https://github.com/python/peps/blob/master/pep-0536.txt
...consts.index(value) except ValueError: pos = len(newconsts) newconsts.append(value) newcode[i] = LOAD_CONST newcode[i+1] = pos & 0xFF newcode[i+2] = pos >> 8 if verbose: print name, '-->', value i += 1 if opcode >= HAVE_ARGUMENT: i += 2 codestr = ''.join(map(chr, newcode)) codeobj = type(co)(co.co_argcount...