/src/cpython/Include/cpython/objimpl.h
Line | Count | Source |
1 | | #ifndef Py_CPYTHON_OBJIMPL_H |
2 | | # error "this header file must not be included directly" |
3 | | #endif |
4 | | |
5 | 235M | static inline size_t _PyObject_SIZE(PyTypeObject *type) { |
6 | 235M | return _Py_STATIC_CAST(size_t, type->tp_basicsize); |
7 | 235M | } Unexecuted instantiation: bytesobject.c:_PyObject_SIZE Unexecuted instantiation: call.c:_PyObject_SIZE Unexecuted instantiation: exceptions.c:_PyObject_SIZE Unexecuted instantiation: genericaliasobject.c:_PyObject_SIZE Unexecuted instantiation: floatobject.c:_PyObject_SIZE Unexecuted instantiation: listobject.c:_PyObject_SIZE Unexecuted instantiation: longobject.c:_PyObject_SIZE Unexecuted instantiation: dictobject.c:_PyObject_SIZE Unexecuted instantiation: memoryobject.c:_PyObject_SIZE Unexecuted instantiation: moduleobject.c:_PyObject_SIZE Line | Count | Source | 5 | 2.78M | static inline size_t _PyObject_SIZE(PyTypeObject *type) { | 6 | 2.78M | return _Py_STATIC_CAST(size_t, type->tp_basicsize); | 7 | 2.78M | } |
Unexecuted instantiation: obmalloc.c:_PyObject_SIZE Unexecuted instantiation: picklebufobject.c:_PyObject_SIZE Unexecuted instantiation: rangeobject.c:_PyObject_SIZE Unexecuted instantiation: setobject.c:_PyObject_SIZE Unexecuted instantiation: sliceobject.c:_PyObject_SIZE Unexecuted instantiation: structseq.c:_PyObject_SIZE Unexecuted instantiation: templateobject.c:_PyObject_SIZE Unexecuted instantiation: tupleobject.c:_PyObject_SIZE Unexecuted instantiation: typeobject.c:_PyObject_SIZE Unexecuted instantiation: typevarobject.c:_PyObject_SIZE Unexecuted instantiation: unicode_format.c:_PyObject_SIZE Unexecuted instantiation: unicode_formatter.c:_PyObject_SIZE Unexecuted instantiation: unicode_writer.c:_PyObject_SIZE Unexecuted instantiation: unicodectype.c:_PyObject_SIZE Unexecuted instantiation: unicodeobject.c:_PyObject_SIZE Unexecuted instantiation: unionobject.c:_PyObject_SIZE Unexecuted instantiation: weakrefobject.c:_PyObject_SIZE Unexecuted instantiation: _warnings.c:_PyObject_SIZE Unexecuted instantiation: bltinmodule.c:_PyObject_SIZE Unexecuted instantiation: ceval.c:_PyObject_SIZE Unexecuted instantiation: codecs.c:_PyObject_SIZE Unexecuted instantiation: codegen.c:_PyObject_SIZE Unexecuted instantiation: compile.c:_PyObject_SIZE Unexecuted instantiation: context.c:_PyObject_SIZE Unexecuted instantiation: errors.c:_PyObject_SIZE Unexecuted instantiation: flowgraph.c:_PyObject_SIZE Unexecuted instantiation: frame.c:_PyObject_SIZE Unexecuted instantiation: future.c:_PyObject_SIZE Line | Count | Source | 5 | 232M | static inline size_t _PyObject_SIZE(PyTypeObject *type) { | 6 | 232M | return _Py_STATIC_CAST(size_t, type->tp_basicsize); | 7 | 232M | } |
Unexecuted instantiation: gc_gil.c:_PyObject_SIZE Unexecuted instantiation: getargs.c:_PyObject_SIZE Unexecuted instantiation: ceval_gil.c:_PyObject_SIZE Unexecuted instantiation: hamt.c:_PyObject_SIZE Unexecuted instantiation: hashtable.c:_PyObject_SIZE Unexecuted instantiation: import.c:_PyObject_SIZE Unexecuted instantiation: importdl.c:_PyObject_SIZE Unexecuted instantiation: initconfig.c:_PyObject_SIZE Unexecuted instantiation: instrumentation.c:_PyObject_SIZE Unexecuted instantiation: instruction_sequence.c:_PyObject_SIZE Unexecuted instantiation: intrinsics.c:_PyObject_SIZE Unexecuted instantiation: legacy_tracing.c:_PyObject_SIZE Unexecuted instantiation: lock.c:_PyObject_SIZE Unexecuted instantiation: marshal.c:_PyObject_SIZE Unexecuted instantiation: modsupport.c:_PyObject_SIZE Unexecuted instantiation: mysnprintf.c:_PyObject_SIZE Unexecuted instantiation: parking_lot.c:_PyObject_SIZE Unexecuted instantiation: preconfig.c:_PyObject_SIZE Unexecuted instantiation: pyarena.c:_PyObject_SIZE Unexecuted instantiation: pyctype.c:_PyObject_SIZE Unexecuted instantiation: pyhash.c:_PyObject_SIZE Unexecuted instantiation: pylifecycle.c:_PyObject_SIZE Unexecuted instantiation: pymath.c:_PyObject_SIZE Unexecuted instantiation: pystate.c:_PyObject_SIZE Unexecuted instantiation: pythonrun.c:_PyObject_SIZE Unexecuted instantiation: pytime.c:_PyObject_SIZE Unexecuted instantiation: qsbr.c:_PyObject_SIZE Unexecuted instantiation: bootstrap_hash.c:_PyObject_SIZE Unexecuted instantiation: specialize.c:_PyObject_SIZE Unexecuted instantiation: structmember.c:_PyObject_SIZE Unexecuted instantiation: symtable.c:_PyObject_SIZE Unexecuted instantiation: sysmodule.c:_PyObject_SIZE Unexecuted instantiation: thread.c:_PyObject_SIZE Unexecuted instantiation: traceback.c:_PyObject_SIZE Unexecuted instantiation: tracemalloc.c:_PyObject_SIZE Unexecuted instantiation: getopt.c:_PyObject_SIZE Unexecuted instantiation: pystrcmp.c:_PyObject_SIZE Unexecuted instantiation: pystrtod.c:_PyObject_SIZE Unexecuted instantiation: pystrhex.c:_PyObject_SIZE Unexecuted instantiation: dtoa.c:_PyObject_SIZE Unexecuted instantiation: fileutils.c:_PyObject_SIZE Unexecuted instantiation: suggestions.c:_PyObject_SIZE Unexecuted instantiation: perf_trampoline.c:_PyObject_SIZE Unexecuted instantiation: perf_jit_trampoline.c:_PyObject_SIZE Unexecuted instantiation: remote_debugging.c:_PyObject_SIZE Unexecuted instantiation: dynload_shlib.c:_PyObject_SIZE Unexecuted instantiation: config.c:_PyObject_SIZE Unexecuted instantiation: gcmodule.c:_PyObject_SIZE Unexecuted instantiation: _asynciomodule.c:_PyObject_SIZE Unexecuted instantiation: atexitmodule.c:_PyObject_SIZE Unexecuted instantiation: faulthandler.c:_PyObject_SIZE Unexecuted instantiation: posixmodule.c:_PyObject_SIZE Unexecuted instantiation: signalmodule.c:_PyObject_SIZE Unexecuted instantiation: _tracemalloc.c:_PyObject_SIZE Unexecuted instantiation: _suggestions.c:_PyObject_SIZE Unexecuted instantiation: _datetimemodule.c:_PyObject_SIZE Unexecuted instantiation: _codecsmodule.c:_PyObject_SIZE Unexecuted instantiation: _collectionsmodule.c:_PyObject_SIZE Unexecuted instantiation: _iomodule.c:_PyObject_SIZE Unexecuted instantiation: iobase.c:_PyObject_SIZE Unexecuted instantiation: fileio.c:_PyObject_SIZE Unexecuted instantiation: bytesio.c:_PyObject_SIZE Unexecuted instantiation: bufferedio.c:_PyObject_SIZE Unexecuted instantiation: textio.c:_PyObject_SIZE Unexecuted instantiation: stringio.c:_PyObject_SIZE Unexecuted instantiation: itertoolsmodule.c:_PyObject_SIZE Unexecuted instantiation: sre.c:_PyObject_SIZE Unexecuted instantiation: _sysconfig.c:_PyObject_SIZE Unexecuted instantiation: _threadmodule.c:_PyObject_SIZE Unexecuted instantiation: timemodule.c:_PyObject_SIZE Unexecuted instantiation: _typesmodule.c:_PyObject_SIZE Unexecuted instantiation: _typingmodule.c:_PyObject_SIZE Unexecuted instantiation: _weakref.c:_PyObject_SIZE Unexecuted instantiation: _abc.c:_PyObject_SIZE Unexecuted instantiation: _functoolsmodule.c:_PyObject_SIZE Unexecuted instantiation: _localemodule.c:_PyObject_SIZE Unexecuted instantiation: _opcode.c:_PyObject_SIZE Unexecuted instantiation: _operator.c:_PyObject_SIZE Unexecuted instantiation: symtablemodule.c:_PyObject_SIZE Unexecuted instantiation: pwdmodule.c:_PyObject_SIZE Unexecuted instantiation: getpath.c:_PyObject_SIZE Unexecuted instantiation: frozen.c:_PyObject_SIZE Unexecuted instantiation: getbuildinfo.c:_PyObject_SIZE Unexecuted instantiation: peg_api.c:_PyObject_SIZE Unexecuted instantiation: file_tokenizer.c:_PyObject_SIZE Unexecuted instantiation: helpers.c:_PyObject_SIZE Unexecuted instantiation: myreadline.c:_PyObject_SIZE Unexecuted instantiation: abstract.c:_PyObject_SIZE Unexecuted instantiation: boolobject.c:_PyObject_SIZE Unexecuted instantiation: bytes_methods.c:_PyObject_SIZE Unexecuted instantiation: bytearrayobject.c:_PyObject_SIZE Unexecuted instantiation: capsule.c:_PyObject_SIZE Unexecuted instantiation: cellobject.c:_PyObject_SIZE Unexecuted instantiation: classobject.c:_PyObject_SIZE Unexecuted instantiation: codeobject.c:_PyObject_SIZE Unexecuted instantiation: complexobject.c:_PyObject_SIZE Unexecuted instantiation: descrobject.c:_PyObject_SIZE Unexecuted instantiation: enumobject.c:_PyObject_SIZE Unexecuted instantiation: genobject.c:_PyObject_SIZE Unexecuted instantiation: fileobject.c:_PyObject_SIZE Unexecuted instantiation: frameobject.c:_PyObject_SIZE Unexecuted instantiation: funcobject.c:_PyObject_SIZE Unexecuted instantiation: interpolationobject.c:_PyObject_SIZE Unexecuted instantiation: iterobject.c:_PyObject_SIZE Unexecuted instantiation: lazyimportobject.c:_PyObject_SIZE Unexecuted instantiation: odictobject.c:_PyObject_SIZE Unexecuted instantiation: methodobject.c:_PyObject_SIZE Unexecuted instantiation: namespaceobject.c:_PyObject_SIZE Unexecuted instantiation: _contextvars.c:_PyObject_SIZE Unexecuted instantiation: Python-ast.c:_PyObject_SIZE Unexecuted instantiation: Python-tokenize.c:_PyObject_SIZE Unexecuted instantiation: asdl.c:_PyObject_SIZE Unexecuted instantiation: assemble.c:_PyObject_SIZE Unexecuted instantiation: ast.c:_PyObject_SIZE Unexecuted instantiation: ast_preprocess.c:_PyObject_SIZE Unexecuted instantiation: ast_unparse.c:_PyObject_SIZE Unexecuted instantiation: critical_section.c:_PyObject_SIZE Unexecuted instantiation: crossinterp.c:_PyObject_SIZE Unexecuted instantiation: getcopyright.c:_PyObject_SIZE Unexecuted instantiation: getplatform.c:_PyObject_SIZE Unexecuted instantiation: getversion.c:_PyObject_SIZE Unexecuted instantiation: optimizer.c:_PyObject_SIZE Unexecuted instantiation: pathconfig.c:_PyObject_SIZE Unexecuted instantiation: pegen.c:_PyObject_SIZE Unexecuted instantiation: pegen_errors.c:_PyObject_SIZE Unexecuted instantiation: parser.c:_PyObject_SIZE Unexecuted instantiation: buffer.c:_PyObject_SIZE Unexecuted instantiation: lexer.c:_PyObject_SIZE Unexecuted instantiation: state.c:_PyObject_SIZE Unexecuted instantiation: readline_tokenizer.c:_PyObject_SIZE Unexecuted instantiation: string_tokenizer.c:_PyObject_SIZE Unexecuted instantiation: utf8_tokenizer.c:_PyObject_SIZE Unexecuted instantiation: getcompiler.c:_PyObject_SIZE Unexecuted instantiation: mystrtoul.c:_PyObject_SIZE Unexecuted instantiation: token.c:_PyObject_SIZE Unexecuted instantiation: action_helpers.c:_PyObject_SIZE Unexecuted instantiation: string_parser.c:_PyObject_SIZE |
8 | | |
9 | | /* _PyObject_VAR_SIZE returns the number of bytes (as size_t) allocated for a |
10 | | vrbl-size object with nitems items, exclusive of gc overhead (if any). The |
11 | | value is rounded up to the closest multiple of sizeof(void *), in order to |
12 | | ensure that pointer fields at the end of the object are correctly aligned |
13 | | for the platform (this is of special importance for subclasses of, e.g., |
14 | | str or int, so that pointers can be stored after the embedded data). |
15 | | |
16 | | Note that there's no memory wastage in doing this, as malloc has to |
17 | | return (at worst) pointer-aligned memory anyway. |
18 | | */ |
19 | | #if ((SIZEOF_VOID_P - 1) & SIZEOF_VOID_P) != 0 |
20 | | # error "_PyObject_VAR_SIZE requires SIZEOF_VOID_P be a power of 2" |
21 | | #endif |
22 | | |
23 | 376M | static inline size_t _PyObject_VAR_SIZE(PyTypeObject *type, Py_ssize_t nitems) { |
24 | 376M | size_t size = _Py_STATIC_CAST(size_t, type->tp_basicsize); |
25 | 376M | size += _Py_STATIC_CAST(size_t, nitems) * _Py_STATIC_CAST(size_t, type->tp_itemsize); |
26 | 376M | return _Py_SIZE_ROUND_UP(size, SIZEOF_VOID_P); |
27 | 376M | } Unexecuted instantiation: bytesobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: call.c:_PyObject_VAR_SIZE Unexecuted instantiation: exceptions.c:_PyObject_VAR_SIZE Unexecuted instantiation: genericaliasobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: floatobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: listobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: longobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: dictobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: memoryobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: moduleobject.c:_PyObject_VAR_SIZE object.c:_PyObject_VAR_SIZE Line | Count | Source | 23 | 185k | static inline size_t _PyObject_VAR_SIZE(PyTypeObject *type, Py_ssize_t nitems) { | 24 | 185k | size_t size = _Py_STATIC_CAST(size_t, type->tp_basicsize); | 25 | 185k | size += _Py_STATIC_CAST(size_t, nitems) * _Py_STATIC_CAST(size_t, type->tp_itemsize); | 26 | 185k | return _Py_SIZE_ROUND_UP(size, SIZEOF_VOID_P); | 27 | 185k | } |
Unexecuted instantiation: obmalloc.c:_PyObject_VAR_SIZE Unexecuted instantiation: picklebufobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: rangeobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: setobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: sliceobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: structseq.c:_PyObject_VAR_SIZE Unexecuted instantiation: templateobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: tupleobject.c:_PyObject_VAR_SIZE typeobject.c:_PyObject_VAR_SIZE Line | Count | Source | 23 | 161M | static inline size_t _PyObject_VAR_SIZE(PyTypeObject *type, Py_ssize_t nitems) { | 24 | 161M | size_t size = _Py_STATIC_CAST(size_t, type->tp_basicsize); | 25 | 161M | size += _Py_STATIC_CAST(size_t, nitems) * _Py_STATIC_CAST(size_t, type->tp_itemsize); | 26 | 161M | return _Py_SIZE_ROUND_UP(size, SIZEOF_VOID_P); | 27 | 161M | } |
Unexecuted instantiation: typevarobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: unicode_format.c:_PyObject_VAR_SIZE Unexecuted instantiation: unicode_formatter.c:_PyObject_VAR_SIZE Unexecuted instantiation: unicode_writer.c:_PyObject_VAR_SIZE Unexecuted instantiation: unicodectype.c:_PyObject_VAR_SIZE Unexecuted instantiation: unicodeobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: unionobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: weakrefobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: _warnings.c:_PyObject_VAR_SIZE Unexecuted instantiation: bltinmodule.c:_PyObject_VAR_SIZE Unexecuted instantiation: ceval.c:_PyObject_VAR_SIZE Unexecuted instantiation: codecs.c:_PyObject_VAR_SIZE Unexecuted instantiation: codegen.c:_PyObject_VAR_SIZE Unexecuted instantiation: compile.c:_PyObject_VAR_SIZE Unexecuted instantiation: context.c:_PyObject_VAR_SIZE Unexecuted instantiation: errors.c:_PyObject_VAR_SIZE Unexecuted instantiation: flowgraph.c:_PyObject_VAR_SIZE Unexecuted instantiation: frame.c:_PyObject_VAR_SIZE Unexecuted instantiation: future.c:_PyObject_VAR_SIZE Line | Count | Source | 23 | 215M | static inline size_t _PyObject_VAR_SIZE(PyTypeObject *type, Py_ssize_t nitems) { | 24 | 215M | size_t size = _Py_STATIC_CAST(size_t, type->tp_basicsize); | 25 | 215M | size += _Py_STATIC_CAST(size_t, nitems) * _Py_STATIC_CAST(size_t, type->tp_itemsize); | 26 | 215M | return _Py_SIZE_ROUND_UP(size, SIZEOF_VOID_P); | 27 | 215M | } |
Unexecuted instantiation: gc_gil.c:_PyObject_VAR_SIZE Unexecuted instantiation: getargs.c:_PyObject_VAR_SIZE Unexecuted instantiation: ceval_gil.c:_PyObject_VAR_SIZE Unexecuted instantiation: hamt.c:_PyObject_VAR_SIZE Unexecuted instantiation: hashtable.c:_PyObject_VAR_SIZE Unexecuted instantiation: import.c:_PyObject_VAR_SIZE Unexecuted instantiation: importdl.c:_PyObject_VAR_SIZE Unexecuted instantiation: initconfig.c:_PyObject_VAR_SIZE Unexecuted instantiation: instrumentation.c:_PyObject_VAR_SIZE Unexecuted instantiation: instruction_sequence.c:_PyObject_VAR_SIZE Unexecuted instantiation: intrinsics.c:_PyObject_VAR_SIZE Unexecuted instantiation: legacy_tracing.c:_PyObject_VAR_SIZE Unexecuted instantiation: lock.c:_PyObject_VAR_SIZE Unexecuted instantiation: marshal.c:_PyObject_VAR_SIZE Unexecuted instantiation: modsupport.c:_PyObject_VAR_SIZE Unexecuted instantiation: mysnprintf.c:_PyObject_VAR_SIZE Unexecuted instantiation: parking_lot.c:_PyObject_VAR_SIZE Unexecuted instantiation: preconfig.c:_PyObject_VAR_SIZE Unexecuted instantiation: pyarena.c:_PyObject_VAR_SIZE Unexecuted instantiation: pyctype.c:_PyObject_VAR_SIZE Unexecuted instantiation: pyhash.c:_PyObject_VAR_SIZE Unexecuted instantiation: pylifecycle.c:_PyObject_VAR_SIZE Unexecuted instantiation: pymath.c:_PyObject_VAR_SIZE Unexecuted instantiation: pystate.c:_PyObject_VAR_SIZE Unexecuted instantiation: pythonrun.c:_PyObject_VAR_SIZE Unexecuted instantiation: pytime.c:_PyObject_VAR_SIZE Unexecuted instantiation: qsbr.c:_PyObject_VAR_SIZE Unexecuted instantiation: bootstrap_hash.c:_PyObject_VAR_SIZE Unexecuted instantiation: specialize.c:_PyObject_VAR_SIZE Unexecuted instantiation: structmember.c:_PyObject_VAR_SIZE Unexecuted instantiation: symtable.c:_PyObject_VAR_SIZE Unexecuted instantiation: sysmodule.c:_PyObject_VAR_SIZE Unexecuted instantiation: thread.c:_PyObject_VAR_SIZE Unexecuted instantiation: traceback.c:_PyObject_VAR_SIZE Unexecuted instantiation: tracemalloc.c:_PyObject_VAR_SIZE Unexecuted instantiation: getopt.c:_PyObject_VAR_SIZE Unexecuted instantiation: pystrcmp.c:_PyObject_VAR_SIZE Unexecuted instantiation: pystrtod.c:_PyObject_VAR_SIZE Unexecuted instantiation: pystrhex.c:_PyObject_VAR_SIZE Unexecuted instantiation: dtoa.c:_PyObject_VAR_SIZE Unexecuted instantiation: fileutils.c:_PyObject_VAR_SIZE Unexecuted instantiation: suggestions.c:_PyObject_VAR_SIZE Unexecuted instantiation: perf_trampoline.c:_PyObject_VAR_SIZE Unexecuted instantiation: perf_jit_trampoline.c:_PyObject_VAR_SIZE Unexecuted instantiation: remote_debugging.c:_PyObject_VAR_SIZE Unexecuted instantiation: dynload_shlib.c:_PyObject_VAR_SIZE Unexecuted instantiation: config.c:_PyObject_VAR_SIZE Unexecuted instantiation: gcmodule.c:_PyObject_VAR_SIZE Unexecuted instantiation: _asynciomodule.c:_PyObject_VAR_SIZE Unexecuted instantiation: atexitmodule.c:_PyObject_VAR_SIZE Unexecuted instantiation: faulthandler.c:_PyObject_VAR_SIZE Unexecuted instantiation: posixmodule.c:_PyObject_VAR_SIZE Unexecuted instantiation: signalmodule.c:_PyObject_VAR_SIZE Unexecuted instantiation: _tracemalloc.c:_PyObject_VAR_SIZE Unexecuted instantiation: _suggestions.c:_PyObject_VAR_SIZE Unexecuted instantiation: _datetimemodule.c:_PyObject_VAR_SIZE Unexecuted instantiation: _codecsmodule.c:_PyObject_VAR_SIZE Unexecuted instantiation: _collectionsmodule.c:_PyObject_VAR_SIZE Unexecuted instantiation: _iomodule.c:_PyObject_VAR_SIZE Unexecuted instantiation: iobase.c:_PyObject_VAR_SIZE Unexecuted instantiation: fileio.c:_PyObject_VAR_SIZE Unexecuted instantiation: bytesio.c:_PyObject_VAR_SIZE Unexecuted instantiation: bufferedio.c:_PyObject_VAR_SIZE Unexecuted instantiation: textio.c:_PyObject_VAR_SIZE Unexecuted instantiation: stringio.c:_PyObject_VAR_SIZE Unexecuted instantiation: itertoolsmodule.c:_PyObject_VAR_SIZE Unexecuted instantiation: sre.c:_PyObject_VAR_SIZE Unexecuted instantiation: _sysconfig.c:_PyObject_VAR_SIZE Unexecuted instantiation: _threadmodule.c:_PyObject_VAR_SIZE Unexecuted instantiation: timemodule.c:_PyObject_VAR_SIZE Unexecuted instantiation: _typesmodule.c:_PyObject_VAR_SIZE Unexecuted instantiation: _typingmodule.c:_PyObject_VAR_SIZE Unexecuted instantiation: _weakref.c:_PyObject_VAR_SIZE Unexecuted instantiation: _abc.c:_PyObject_VAR_SIZE Unexecuted instantiation: _functoolsmodule.c:_PyObject_VAR_SIZE Unexecuted instantiation: _localemodule.c:_PyObject_VAR_SIZE Unexecuted instantiation: _opcode.c:_PyObject_VAR_SIZE Unexecuted instantiation: _operator.c:_PyObject_VAR_SIZE Unexecuted instantiation: symtablemodule.c:_PyObject_VAR_SIZE Unexecuted instantiation: pwdmodule.c:_PyObject_VAR_SIZE Unexecuted instantiation: getpath.c:_PyObject_VAR_SIZE Unexecuted instantiation: frozen.c:_PyObject_VAR_SIZE Unexecuted instantiation: getbuildinfo.c:_PyObject_VAR_SIZE Unexecuted instantiation: peg_api.c:_PyObject_VAR_SIZE Unexecuted instantiation: file_tokenizer.c:_PyObject_VAR_SIZE Unexecuted instantiation: helpers.c:_PyObject_VAR_SIZE Unexecuted instantiation: myreadline.c:_PyObject_VAR_SIZE Unexecuted instantiation: abstract.c:_PyObject_VAR_SIZE Unexecuted instantiation: boolobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: bytes_methods.c:_PyObject_VAR_SIZE Unexecuted instantiation: bytearrayobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: capsule.c:_PyObject_VAR_SIZE Unexecuted instantiation: cellobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: classobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: codeobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: complexobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: descrobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: enumobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: genobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: fileobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: frameobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: funcobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: interpolationobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: iterobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: lazyimportobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: odictobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: methodobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: namespaceobject.c:_PyObject_VAR_SIZE Unexecuted instantiation: _contextvars.c:_PyObject_VAR_SIZE Unexecuted instantiation: Python-ast.c:_PyObject_VAR_SIZE Unexecuted instantiation: Python-tokenize.c:_PyObject_VAR_SIZE Unexecuted instantiation: asdl.c:_PyObject_VAR_SIZE Unexecuted instantiation: assemble.c:_PyObject_VAR_SIZE Unexecuted instantiation: ast.c:_PyObject_VAR_SIZE Unexecuted instantiation: ast_preprocess.c:_PyObject_VAR_SIZE Unexecuted instantiation: ast_unparse.c:_PyObject_VAR_SIZE Unexecuted instantiation: critical_section.c:_PyObject_VAR_SIZE Unexecuted instantiation: crossinterp.c:_PyObject_VAR_SIZE Unexecuted instantiation: getcopyright.c:_PyObject_VAR_SIZE Unexecuted instantiation: getplatform.c:_PyObject_VAR_SIZE Unexecuted instantiation: getversion.c:_PyObject_VAR_SIZE Unexecuted instantiation: optimizer.c:_PyObject_VAR_SIZE Unexecuted instantiation: pathconfig.c:_PyObject_VAR_SIZE Unexecuted instantiation: pegen.c:_PyObject_VAR_SIZE Unexecuted instantiation: pegen_errors.c:_PyObject_VAR_SIZE Unexecuted instantiation: parser.c:_PyObject_VAR_SIZE Unexecuted instantiation: buffer.c:_PyObject_VAR_SIZE Unexecuted instantiation: lexer.c:_PyObject_VAR_SIZE Unexecuted instantiation: state.c:_PyObject_VAR_SIZE Unexecuted instantiation: readline_tokenizer.c:_PyObject_VAR_SIZE Unexecuted instantiation: string_tokenizer.c:_PyObject_VAR_SIZE Unexecuted instantiation: utf8_tokenizer.c:_PyObject_VAR_SIZE Unexecuted instantiation: getcompiler.c:_PyObject_VAR_SIZE Unexecuted instantiation: mystrtoul.c:_PyObject_VAR_SIZE Unexecuted instantiation: token.c:_PyObject_VAR_SIZE Unexecuted instantiation: action_helpers.c:_PyObject_VAR_SIZE Unexecuted instantiation: string_parser.c:_PyObject_VAR_SIZE |
28 | | |
29 | | |
30 | | /* This example code implements an object constructor with a custom |
31 | | allocator, where PyObject_New is inlined, and shows the important |
32 | | distinction between two steps (at least): |
33 | | 1) the actual allocation of the object storage; |
34 | | 2) the initialization of the Python specific fields |
35 | | in this storage with PyObject_{Init, InitVar}. |
36 | | |
37 | | PyObject * |
38 | | YourObject_New(...) |
39 | | { |
40 | | PyObject *op; |
41 | | |
42 | | op = (PyObject *) Your_Allocator(_PyObject_SIZE(YourTypeStruct)); |
43 | | if (op == NULL) { |
44 | | return PyErr_NoMemory(); |
45 | | } |
46 | | |
47 | | PyObject_Init(op, &YourTypeStruct); |
48 | | |
49 | | op->ob_field = value; |
50 | | ... |
51 | | return op; |
52 | | } |
53 | | |
54 | | Note that in C++, the use of the new operator usually implies that |
55 | | the 1st step is performed automatically for you, so in a C++ class |
56 | | constructor you would start directly with PyObject_Init/InitVar. */ |
57 | | |
58 | | |
59 | | typedef struct { |
60 | | /* user context passed as the first argument to the 2 functions */ |
61 | | void *ctx; |
62 | | |
63 | | /* allocate an arena of size bytes */ |
64 | | void* (*alloc) (void *ctx, size_t size); |
65 | | |
66 | | /* free an arena */ |
67 | | void (*free) (void *ctx, void *ptr, size_t size); |
68 | | } PyObjectArenaAllocator; |
69 | | |
70 | | /* Get the arena allocator. */ |
71 | | PyAPI_FUNC(void) PyObject_GetArenaAllocator(PyObjectArenaAllocator *allocator); |
72 | | |
73 | | /* Set the arena allocator. */ |
74 | | PyAPI_FUNC(void) PyObject_SetArenaAllocator(PyObjectArenaAllocator *allocator); |
75 | | |
76 | | |
77 | | /* Test if an object implements the garbage collector protocol */ |
78 | | PyAPI_FUNC(int) PyObject_IS_GC(PyObject *obj); |
79 | | |
80 | | |
81 | | // Test if a type supports weak references |
82 | | PyAPI_FUNC(int) PyType_SUPPORTS_WEAKREFS(PyTypeObject *type); |
83 | | |
84 | | PyAPI_FUNC(PyObject **) PyObject_GET_WEAKREFS_LISTPTR(PyObject *op); |
85 | | |
86 | | PyAPI_FUNC(PyObject *) PyUnstable_Object_GC_NewWithExtraData(PyTypeObject *, |
87 | | size_t); |
88 | | |
89 | | |
90 | | /* Visit all live GC-capable objects, similar to gc.get_objects(None). The |
91 | | * supplied callback is called on every such object with the void* arg set |
92 | | * to the supplied arg. Returning 0 from the callback ends iteration, returning |
93 | | * 1 allows iteration to continue. Returning any other value may result in |
94 | | * undefined behaviour. |
95 | | * |
96 | | * If new objects are (de)allocated by the callback it is undefined if they |
97 | | * will be visited. |
98 | | |
99 | | * Garbage collection is disabled during operation. Explicitly running a |
100 | | * collection in the callback may lead to undefined behaviour e.g. visiting the |
101 | | * same objects multiple times or not at all. |
102 | | */ |
103 | | typedef int (*gcvisitobjects_t)(PyObject*, void*); |
104 | | PyAPI_FUNC(void) PyUnstable_GC_VisitObjects(gcvisitobjects_t callback, void* arg); |