chunk_id
stringlengths
36
36
source
stringclasses
35 values
source_url
stringlengths
0
290
upstream_license
stringclasses
1 value
document_id
stringlengths
36
36
chunk_index
int64
0
324k
retrieved_at
stringclasses
2 values
chunker_version
stringclasses
4 values
content_hash
stringlengths
15
64
content
stringlengths
50
44.7k
namespace
stringclasses
9 values
source_name
stringclasses
35 values
raw_text
stringlengths
50
44.7k
cleaned_text
stringlengths
50
44.7k
tags
stringclasses
49 values
collection_name
stringclasses
11 values
70150311-37b0-495b-aa5f-5eb89bdcfc82
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,895
supabase-export-v2
021bb856a1ef4777
Replace ``o = PyObject_NewVar(TYPE, typeobj, size)`` with the same, but use size instead of the 0. - If the above is not possible (e.g. inside a custom ``tp_alloc``), call :c:func:`PyObject_GC_New` or :c:func:`PyObject_GC_NewVar`::
trusted_official_docs
CPython Docs
Replace ``o = PyObject_NewVar(TYPE, typeobj, size)`` with the same, but use size instead of the 0. - If the above is not possible (e.g. inside a custom ``tp_alloc``), call :c:func:`PyObject_GC_New` or :c:func:`PyObject_GC_NewVar`::
Replace ``o = PyObject_NewVar(TYPE, typeobj, size)`` with the same, but use size instead of the 0. - If the above is not possible (e.g. inside a custom ``tp_alloc``), call :c:func:`PyObject_GC_New` or :c:func:`PyObject_GC_NewVar`::
python, official-docs, cpython, P0
Local_Trusted_Corpus
7216fa4b-9632-4f24-9d90-b1314b066b02
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,818
supabase-export-v2
a28b66a27c4f66be
this just is a rule of thumb, exceptions are possible (see `Managing Global State`_), but they will need more thought and attention to edge cases. While some modules could do with less stringent restrictions, isolated modules make it easier to set clear expectations and guidelines that work across a variety of use case...
trusted_official_docs
CPython Docs
this just is a rule of thumb, exceptions are possible (see `Managing Global State`_), but they will need more thought and attention to edge cases. While some modules could do with less stringent restrictions, isolated modules make it easier to set clear expectations and guidelines that work across a variety of use case...
this just is a rule of thumb, exceptions are possible (see `Managing Global State`_), but they will need more thought and attention to edge cases. While some modules could do with less stringent restrictions, isolated modules make it easier to set clear expectations and guidelines that work across a variety of use case...
python, official-docs, cpython, P0
Local_Trusted_Corpus
7326eef6-11ac-4458-ae48-421ee0bd4f8a
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,844
supabase-export-v2
af5fa060d490661e
(loaded) { PyMutex_Unlock(&modinit_mutex); PyErr_SetString(PyExc_ImportError, "cannot load module more than once per process"); return -1; } loaded = 1; PyMutex_Unlock(&modinit_mutex); // ... rest of initialization } If your module's :c:member:`PyModuleDef.m_clear` function is able to prepare for future re-initializati...
trusted_official_docs
CPython Docs
(loaded) { PyMutex_Unlock(&modinit_mutex); PyErr_SetString(PyExc_ImportError, "cannot load module more than once per process"); return -1; } loaded = 1; PyMutex_Unlock(&modinit_mutex); // ... rest of initialization } If your module's :c:member:`PyModuleDef.m_clear` function is able to prepare for future re-initializati...
(loaded) { PyMutex_Unlock(&modinit_mutex); PyErr_SetString(PyExc_ImportError, "cannot load module more than once per process"); return -1; } loaded = 1; PyMutex_Unlock(&modinit_mutex); // ... rest of initialization } If your module's :c:member:`PyModuleDef.m_clear` function is able to prepare for future re-initializati...
python, official-docs, cpython, P0
Local_Trusted_Corpus
7933c867-d348-47f9-8f53-b539dd4020a4
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,886
supabase-export-v2
73954ad148191843
static void my_dealloc(PyObject *self) { PyObject_GC_UnTrack(self); ... PyTypeObject *type = Py_TYPE(self); type->tp_free(self); Py_DECREF(type); } The default ``tp_dealloc`` function does this, so if your type does *not* override ``tp_dealloc`` you don't need to add it.
trusted_official_docs
CPython Docs
static void my_dealloc(PyObject *self) { PyObject_GC_UnTrack(self); ... PyTypeObject *type = Py_TYPE(self); type->tp_free(self); Py_DECREF(type); } The default ``tp_dealloc`` function does this, so if your type does *not* override ``tp_dealloc`` you don't need to add it.
static void my_dealloc(PyObject *self) { PyObject_GC_UnTrack(self); ... PyTypeObject *type = Py_TYPE(self); type->tp_free(self); Py_DECREF(type); } The default ``tp_dealloc`` function does this, so if your type does *not* override ``tp_dealloc`` you don't need to add it.
python, official-docs, cpython, P0
Local_Trusted_Corpus
80d625c8-fa97-4005-ae5d-93e0c28a5254
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,899
supabase-export-v2
e09ca10b0741fc86
Module State Access from Classes -------------------------------- If you have a type object defined with :c:func:`PyType_FromModuleAndSpec`, you can call :c:func:`PyType_GetModule` to get the associated module, and then :c:func:`PyModule_GetState` to get the module's state.
trusted_official_docs
CPython Docs
Module State Access from Classes -------------------------------- If you have a type object defined with :c:func:`PyType_FromModuleAndSpec`, you can call :c:func:`PyType_GetModule` to get the associated module, and then :c:func:`PyModule_GetState` to get the module's state.
Module State Access from Classes -------------------------------- If you have a type object defined with :c:func:`PyType_FromModuleAndSpec`, you can call :c:func:`PyType_GetModule` to get the associated module, and then :c:func:`PyModule_GetState` to get the module's state.
python, official-docs, cpython, P0
Local_Trusted_Corpus
8174bfac-2dff-4eee-a9e9-f71e7acd5ba0
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,879
supabase-export-v2
e637ce79853b047a
...and ``base`` may be a static type, then it should also include:: if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { if (Py_Version >= 0x03090000) { Py_VISIT(Py_TYPE(self)); } }
trusted_official_docs
CPython Docs
...and ``base`` may be a static type, then it should also include:: if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { if (Py_Version >= 0x03090000) { Py_VISIT(Py_TYPE(self)); } }
...and ``base`` may be a static type, then it should also include:: if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) { // a heap type's tp_traverse already visited Py_TYPE(self) } else { if (Py_Version >= 0x03090000) { Py_VISIT(Py_TYPE(self)); } }
python, official-docs, cpython, P0
Local_Trusted_Corpus
82d8c780-dfc5-4419-8724-6f7f30678601
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,814
supabase-export-v2
5b479db498b9f4a5
Isolated Module Objects ----------------------- The key point to keep in mind when developing an extension module is that several module objects can be created from a single shared library. For example:
trusted_official_docs
CPython Docs
Isolated Module Objects ----------------------- The key point to keep in mind when developing an extension module is that several module objects can be created from a single shared library. For example:
Isolated Module Objects ----------------------- The key point to keep in mind when developing an extension module is that several module objects can be created from a single shared library. For example:
python, official-docs, cpython, P0
Local_Trusted_Corpus
8b6f8ee2-16b6-44cc-a845-6750eded5d03
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,837
supabase-export-v2
ae055789ac92a4bb
of a class. Adding them will require some work and make the code longer; this is the price for modules which can be unloaded cleanly. An example of a module with per-module state is currently available as `xxlimited <https://github.com/python/cpython/blob/master/Modules/xxlimited.c>`__; example module initialization sh...
trusted_official_docs
CPython Docs
of a class. Adding them will require some work and make the code longer; this is the price for modules which can be unloaded cleanly. An example of a module with per-module state is currently available as `xxlimited <https://github.com/python/cpython/blob/master/Modules/xxlimited.c>`__; example module initialization sh...
of a class. Adding them will require some work and make the code longer; this is the price for modules which can be unloaded cleanly. An example of a module with per-module state is currently available as `xxlimited <https://github.com/python/cpython/blob/master/Modules/xxlimited.c>`__; example module initialization sh...
python, official-docs, cpython, P0
Local_Trusted_Corpus
8ce91488-de2f-4e6c-9ad5-b3e65605ef80
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,853
supabase-export-v2
f109396b7f15cc62
Changes to the refcount are guarded by the GIL. Thus, code that shares any Python objects across interpreters implicitly depends on CPython's current, process-wide GIL. Because they are immutable and process-global, static types cannot access "their" module state. If any method of such a type requires access to module ...
trusted_official_docs
CPython Docs
Changes to the refcount are guarded by the GIL. Thus, code that shares any Python objects across interpreters implicitly depends on CPython's current, process-wide GIL. Because they are immutable and process-global, static types cannot access "their" module state. If any method of such a type requires access to module ...
Changes to the refcount are guarded by the GIL. Thus, code that shares any Python objects across interpreters implicitly depends on CPython's current, process-wide GIL. Because they are immutable and process-global, static types cannot access "their" module state. If any method of such a type requires access to module ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
8fc8bfd5-73f3-43b6-805d-52f45d4ee7aa
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,937
supabase-export-v2
df2779be1f269040
Lossless Conversion to Heap Types --------------------------------- The heap type API was not designed for "lossless" conversion from static types; that is, creating a type that works exactly like a given static type.
trusted_official_docs
CPython Docs
Lossless Conversion to Heap Types --------------------------------- The heap type API was not designed for "lossless" conversion from static types; that is, creating a type that works exactly like a given static type.
Lossless Conversion to Heap Types --------------------------------- The heap type API was not designed for "lossless" conversion from static types; that is, creating a type that works exactly like a given static type.
python, official-docs, cpython, P0
Local_Trusted_Corpus
90fa309f-463f-4fc2-94b6-83fe17d005c5
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,828
supabase-export-v2
eb57ff11a4a8a8fc
with a Python module is not specific to that module, but to the entire process (or something else "more global" than a module). For example: - The ``readline`` module manages *the* terminal. - A module running on a circuit board wants to control *the* on-board LED.
trusted_official_docs
CPython Docs
with a Python module is not specific to that module, but to the entire process (or something else "more global" than a module). For example: - The ``readline`` module manages *the* terminal. - A module running on a circuit board wants to control *the* on-board LED.
with a Python module is not specific to that module, but to the entire process (or something else "more global" than a module). For example: - The ``readline`` module manages *the* terminal. - A module running on a circuit board wants to control *the* on-board LED.
python, official-docs, cpython, P0
Local_Trusted_Corpus
912b8854-a8ac-4a59-b9c1-44f6ba690587
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,835
supabase-export-v2
7aa2f64288f5b6fa
``__dict__`` from Python code. This usually means error- and type-checking at the C level, which is easy to get wrong and hard to test sufficiently. However, if module state is not needed in C code, storing it in ``__dict__`` only is a good idea.
trusted_official_docs
CPython Docs
``__dict__`` from Python code. This usually means error- and type-checking at the C level, which is easy to get wrong and hard to test sufficiently. However, if module state is not needed in C code, storing it in ``__dict__`` only is a good idea.
``__dict__`` from Python code. This usually means error- and type-checking at the C level, which is easy to get wrong and hard to test sufficiently. However, if module state is not needed in C code, storing it in ``__dict__`` only is a good idea.
python, official-docs, cpython, P0
Local_Trusted_Corpus
9485e414-c8cb-4ac5-bde6-fb89a07dd86b
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,856
supabase-export-v2
8e747a27320c601a
Changing Static Types to Heap Types ----------------------------------- Static types can be converted to heap types, but note that the heap type API was not designed for "lossless" conversion from static types—that is, creating a type that works exactly like a given static type. So, when rewriting the class definition ...
trusted_official_docs
CPython Docs
Changing Static Types to Heap Types ----------------------------------- Static types can be converted to heap types, but note that the heap type API was not designed for "lossless" conversion from static types—that is, creating a type that works exactly like a given static type. So, when rewriting the class definition ...
Changing Static Types to Heap Types ----------------------------------- Static types can be converted to heap types, but note that the heap type API was not designed for "lossless" conversion from static types—that is, creating a type that works exactly like a given static type. So, when rewriting the class definition ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
953119e8-a02b-42d0-9fa9-5fbd6179cffe
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,929
supabase-export-v2
25609e877c9662d9
Lifetime of the Module State ---------------------------- When a module object is garbage-collected, its module state is freed. For each pointer to (a part of) the module state, you must hold a reference to the module object.
trusted_official_docs
CPython Docs
Lifetime of the Module State ---------------------------- When a module object is garbage-collected, its module state is freed. For each pointer to (a part of) the module state, you must hold a reference to the module object.
Lifetime of the Module State ---------------------------- When a module object is garbage-collected, its module state is freed. For each pointer to (a part of) the module state, you must hold a reference to the module object.
python, official-docs, cpython, P0
Local_Trusted_Corpus
a0913144-8d25-434c-9dfc-4ea1d66807e4
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,836
supabase-export-v2
f392215ed17410f4
However, if module state is not needed in C code, storing it in ``__dict__`` only is a good idea. If the module state includes ``PyObject`` pointers, the module object must hold references to those objects and implement the module-level hooks ``m_traverse``, ``m_clear`` and ``m_free``. These work like ``tp_traverse``, ...
trusted_official_docs
CPython Docs
However, if module state is not needed in C code, storing it in ``__dict__`` only is a good idea. If the module state includes ``PyObject`` pointers, the module object must hold references to those objects and implement the module-level hooks ``m_traverse``, ``m_clear`` and ``m_free``. These work like ``tp_traverse``, ...
However, if module state is not needed in C code, storing it in ``__dict__`` only is a good idea. If the module state includes ``PyObject`` pointers, the module object must hold references to those objects and implement the module-level hooks ``m_traverse``, ``m_clear`` and ``m_free``. These work like ``tp_traverse``, ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
a5491326-1044-44a6-bf81-9f5e5c938bfc
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,884
supabase-export-v2
2a360c9f5c1e03b0
- call :c:func:`PyObject_GC_UnTrack` before any fields are invalidated, and - decrement the reference count of the type. To keep the type valid while ``tp_free`` is called, the type's refcount needs to be decremented *after* the instance is deallocated. For example::
trusted_official_docs
CPython Docs
- call :c:func:`PyObject_GC_UnTrack` before any fields are invalidated, and - decrement the reference count of the type. To keep the type valid while ``tp_free`` is called, the type's refcount needs to be decremented *after* the instance is deallocated. For example::
- call :c:func:`PyObject_GC_UnTrack` before any fields are invalidated, and - decrement the reference count of the type. To keep the type valid while ``tp_free`` is called, the type's refcount needs to be decremented *after* the instance is deallocated. For example::
python, official-docs, cpython, P0
Local_Trusted_Corpus
a976faef-00dc-454a-9d54-ab4b633bc4ba
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,923
supabase-export-v2
dd2aaa24951ae237
a very simple API that doesn't allow passing in the defining class, unlike with :c:type:`PyCMethod`. The same goes for getters and setters defined with :c:type:`PyGetSetDef`. To access the module state in these cases, use the :c:func:`PyType_GetModuleByDef` function, and pass in the module definition. Once you have the...
trusted_official_docs
CPython Docs
a very simple API that doesn't allow passing in the defining class, unlike with :c:type:`PyCMethod`. The same goes for getters and setters defined with :c:type:`PyGetSetDef`. To access the module state in these cases, use the :c:func:`PyType_GetModuleByDef` function, and pass in the module definition. Once you have the...
a very simple API that doesn't allow passing in the defining class, unlike with :c:type:`PyCMethod`. The same goes for getters and setters defined with :c:type:`PyGetSetDef`. To access the module state in these cases, use the :c:func:`PyType_GetModuleByDef` function, and pass in the module definition. Once you have the...
python, official-docs, cpython, P0
Local_Trusted_Corpus
ad3f018e-d4e1-4664-9428-d756a5b4a1d2
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,924
supabase-export-v2
969132f8de378899
state in these cases, use the :c:func:`PyType_GetModuleByDef` function, and pass in the module definition. Once you have the module, call :c:func:`PyModule_GetState` to get the state:: PyObject *module = PyType_GetModuleByDef(Py_TYPE(self), &module_def); my_struct *state = (my_struct*)PyModule_GetState(module); if (s...
trusted_official_docs
CPython Docs
state in these cases, use the :c:func:`PyType_GetModuleByDef` function, and pass in the module definition. Once you have the module, call :c:func:`PyModule_GetState` to get the state:: PyObject *module = PyType_GetModuleByDef(Py_TYPE(self), &module_def); my_struct *state = (my_struct*)PyModule_GetState(module); if (s...
state in these cases, use the :c:func:`PyType_GetModuleByDef` function, and pass in the module definition. Once you have the module, call :c:func:`PyModule_GetState` to get the state:: PyObject *module = PyType_GetModuleByDef(Py_TYPE(self), &module_def); my_struct *state = (my_struct*)PyModule_GetState(module); if (s...
python, official-docs, cpython, P0
Local_Trusted_Corpus
b065ecb3-1d26-4eaa-bbb7-d393822242b7
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,912
supabase-export-v2
7759a41b5c67dcac
a method to get its "defining class", it must use the :ref:`METH_METHOD | METH_FASTCALL | METH_KEYWORDS <METH_METHOD-METH_FASTCALL-METH_KEYWORDS>` :c:type:`calling convention <PyMethodDef>` and the corresponding :c:type:`PyCMethod` signature:: PyObject *PyCMethod( PyObject *self, // object the method was called on Py...
trusted_official_docs
CPython Docs
a method to get its "defining class", it must use the :ref:`METH_METHOD | METH_FASTCALL | METH_KEYWORDS <METH_METHOD-METH_FASTCALL-METH_KEYWORDS>` :c:type:`calling convention <PyMethodDef>` and the corresponding :c:type:`PyCMethod` signature:: PyObject *PyCMethod( PyObject *self, // object the method was called on Py...
a method to get its "defining class", it must use the :ref:`METH_METHOD | METH_FASTCALL | METH_KEYWORDS <METH_METHOD-METH_FASTCALL-METH_KEYWORDS>` :c:type:`calling convention <PyMethodDef>` and the corresponding :c:type:`PyCMethod` signature:: PyObject *PyCMethod( PyObject *self, // object the method was called on Py...
python, official-docs, cpython, P0
Local_Trusted_Corpus
b09d994d-8bdc-43c8-a6fb-f5af5c2cc885
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,805
supabase-export-v2
7b2e4718e3efdf54
Python supports running multiple interpreters in one process. There are two cases to think about—users may run interpreters: - in sequence, with several :c:func:`Py_InitializeEx`/:c:func:`Py_FinalizeEx` cycles, and - in parallel, managing "sub-interpreters" using :c:func:`Py_NewInterpreter`/:c:func:`Py_EndInterpreter...
trusted_official_docs
CPython Docs
Python supports running multiple interpreters in one process. There are two cases to think about—users may run interpreters: - in sequence, with several :c:func:`Py_InitializeEx`/:c:func:`Py_FinalizeEx` cycles, and - in parallel, managing "sub-interpreters" using :c:func:`Py_NewInterpreter`/:c:func:`Py_EndInterpreter...
Python supports running multiple interpreters in one process. There are two cases to think about—users may run interpreters: - in sequence, with several :c:func:`Py_InitializeEx`/:c:func:`Py_FinalizeEx` cycles, and - in parallel, managing "sub-interpreters" using :c:func:`Py_NewInterpreter`/:c:func:`Py_EndInterpreter...
python, official-docs, cpython, P0
Local_Trusted_Corpus
b6b7c156-1545-4142-a315-29568c7edf98
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,806
supabase-export-v2
2266271e968adbe1
- in sequence, with several :c:func:`Py_InitializeEx`/:c:func:`Py_FinalizeEx` cycles, and - in parallel, managing "sub-interpreters" using :c:func:`Py_NewInterpreter`/:c:func:`Py_EndInterpreter`. Both cases (and combinations of them) would be most useful when embedding Python within a library. Libraries generally shoul...
trusted_official_docs
CPython Docs
- in sequence, with several :c:func:`Py_InitializeEx`/:c:func:`Py_FinalizeEx` cycles, and - in parallel, managing "sub-interpreters" using :c:func:`Py_NewInterpreter`/:c:func:`Py_EndInterpreter`. Both cases (and combinations of them) would be most useful when embedding Python within a library. Libraries generally shoul...
- in sequence, with several :c:func:`Py_InitializeEx`/:c:func:`Py_FinalizeEx` cycles, and - in parallel, managing "sub-interpreters" using :c:func:`Py_NewInterpreter`/:c:func:`Py_EndInterpreter`. Both cases (and combinations of them) would be most useful when embedding Python within a library. Libraries generally shoul...
python, official-docs, cpython, P0
Local_Trusted_Corpus
bd39599c-eb7e-46f7-91a1-675955d610ac
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,840
supabase-export-v2
6fb735fcf46ee223
Opt-Out: Limiting to One Module Object per Process -------------------------------------------------- A non-negative ``PyModuleDef.m_size`` signals that a module supports multiple interpreters correctly. If this is not yet the case for your module, you can explicitly make your module loadable only once per process. For...
trusted_official_docs
CPython Docs
Opt-Out: Limiting to One Module Object per Process -------------------------------------------------- A non-negative ``PyModuleDef.m_size`` signals that a module supports multiple interpreters correctly. If this is not yet the case for your module, you can explicitly make your module loadable only once per process. For...
Opt-Out: Limiting to One Module Object per Process -------------------------------------------------- A non-negative ``PyModuleDef.m_size`` signals that a module supports multiple interpreters correctly. If this is not yet the case for your module, you can explicitly make your module loadable only once per process. For...
python, official-docs, cpython, P0
Local_Trusted_Corpus
c4b3d863-3fb2-499b-bb3c-fd43830c0109
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,827
supabase-export-v2
e688c1dc5a4f4707
Managing Global State --------------------- Sometimes, the state associated with a Python module is not specific to that module, but to the entire process (or something else "more global" than a module). For example:
trusted_official_docs
CPython Docs
Managing Global State --------------------- Sometimes, the state associated with a Python module is not specific to that module, but to the entire process (or something else "more global" than a module). For example:
Managing Global State --------------------- Sometimes, the state associated with a Python module is not specific to that module, but to the entire process (or something else "more global" than a module). For example:
python, official-docs, cpython, P0
Local_Trusted_Corpus
cb56cdef-10d9-4e2f-9814-9541f0de94c4
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,811
supabase-export-v2
78cad7640deda5be
object, keeping the data separate. For testing the isolation, multiple module objects corresponding to a single extension can even be loaded in a single interpreter. Per-module state provides an easy way to think about lifetime and resource ownership: the extension module will initialize when a module object is created...
trusted_official_docs
CPython Docs
object, keeping the data separate. For testing the isolation, multiple module objects corresponding to a single extension can even be loaded in a single interpreter. Per-module state provides an easy way to think about lifetime and resource ownership: the extension module will initialize when a module object is created...
object, keeping the data separate. For testing the isolation, multiple module objects corresponding to a single extension can even be loaded in a single interpreter. Per-module state provides an easy way to think about lifetime and resource ownership: the extension module will initialize when a module object is created...
python, official-docs, cpython, P0
Local_Trusted_Corpus
cee728f9-7e81-44a6-83d3-84d9b2be2c48
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,858
supabase-export-v2
2a3098e612c9304c
Watch out for the following two points in particular (but note that this is not a comprehensive list): * Unlike static types, heap type objects are mutable by default. Use the :c:macro:`Py_TPFLAGS_IMMUTABLETYPE` flag to prevent mutability. * Heap types inherit :c:member:`~PyTypeObject.tp_new` by default, so it may bec...
trusted_official_docs
CPython Docs
Watch out for the following two points in particular (but note that this is not a comprehensive list): * Unlike static types, heap type objects are mutable by default. Use the :c:macro:`Py_TPFLAGS_IMMUTABLETYPE` flag to prevent mutability. * Heap types inherit :c:member:`~PyTypeObject.tp_new` by default, so it may bec...
Watch out for the following two points in particular (but note that this is not a comprehensive list): * Unlike static types, heap type objects are mutable by default. Use the :c:macro:`Py_TPFLAGS_IMMUTABLETYPE` flag to prevent mutability. * Heap types inherit :c:member:`~PyTypeObject.tp_new` by default, so it may bec...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d345716e-1706-44ac-b0e3-346d6fbfd507
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,843
supabase-export-v2
eef6991bf1f092ce
// Mutex to provide thread safety (only needed for free-threaded Python) static PyMutex modinit_mutex = {0}; static int exec_module(PyObject* module) { PyMutex_Lock(&modinit_mutex); if (loaded) { PyMutex_Unlock(&modinit_mutex); PyErr_SetString(PyExc_ImportError, "cannot load module more than once per process"); ...
trusted_official_docs
CPython Docs
// Mutex to provide thread safety (only needed for free-threaded Python) static PyMutex modinit_mutex = {0}; static int exec_module(PyObject* module) { PyMutex_Lock(&modinit_mutex); if (loaded) { PyMutex_Unlock(&modinit_mutex); PyErr_SetString(PyExc_ImportError, "cannot load module more than once per process"); ...
// Mutex to provide thread safety (only needed for free-threaded Python) static PyMutex modinit_mutex = {0}; static int exec_module(PyObject* module) { PyMutex_Lock(&modinit_mutex); if (loaded) { PyMutex_Unlock(&modinit_mutex); PyErr_SetString(PyExc_ImportError, "cannot load module more than once per process"); ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d405b4d1-9eaa-4dcd-b095-bbde35ed8322
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,816
supabase-export-v2
1a43ef913a064fba
.. code-block:: pycon >>> import sys >>> import binascii >>> old_binascii = binascii >>> del sys.modules['binascii'] >>> import binascii # create a new module object >>> old_binascii == binascii False
trusted_official_docs
CPython Docs
.. code-block:: pycon >>> import sys >>> import binascii >>> old_binascii = binascii >>> del sys.modules['binascii'] >>> import binascii # create a new module object >>> old_binascii == binascii False
.. code-block:: pycon >>> import sys >>> import binascii >>> old_binascii = binascii >>> del sys.modules['binascii'] >>> import binascii # create a new module object >>> old_binascii == binascii False
python, official-docs, cpython, P0
Local_Trusted_Corpus
d61be26a-747e-4eba-88e9-73610279baa8
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,935
supabase-export-v2
a48e131347d67671
Per-Class Scope --------------- It is currently (as of Python 3.11) not possible to attach state to individual *types* without relying on CPython implementation details (which may change in the future—perhaps, ironically, to allow a proper solution for per-class scope).
trusted_official_docs
CPython Docs
Per-Class Scope --------------- It is currently (as of Python 3.11) not possible to attach state to individual *types* without relying on CPython implementation details (which may change in the future—perhaps, ironically, to allow a proper solution for per-class scope).
Per-Class Scope --------------- It is currently (as of Python 3.11) not possible to attach state to individual *types* without relying on CPython implementation details (which may change in the future—perhaps, ironically, to allow a proper solution for per-class scope).
python, official-docs, cpython, P0
Local_Trusted_Corpus
d766df1d-e362-4fa9-8415-47e417959d95
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,901
supabase-export-v2
434c6cbbd9a116ed
To save a some tedious error-handling boilerplate code, you can combine these two steps with :c:func:`PyType_GetModuleState`, resulting in:: my_struct *state = (my_struct*)PyType_GetModuleState(type); if (state == NULL) { return NULL; }
trusted_official_docs
CPython Docs
To save a some tedious error-handling boilerplate code, you can combine these two steps with :c:func:`PyType_GetModuleState`, resulting in:: my_struct *state = (my_struct*)PyType_GetModuleState(type); if (state == NULL) { return NULL; }
To save a some tedious error-handling boilerplate code, you can combine these two steps with :c:func:`PyType_GetModuleState`, resulting in:: my_struct *state = (my_struct*)PyType_GetModuleState(type); if (state == NULL) { return NULL; }
python, official-docs, cpython, P0
Local_Trusted_Corpus
d7e21609-0cdc-4ee9-8b6d-d796dbb28b66
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,824
supabase-export-v2
dda1c2150af58ac5
This is expected. Notice that pure-Python modules behave the same way: it is a part of how Python works. The goal is to make extension modules safe at the C level, not to make hacks behave intuitively. Mutating ``sys.modules`` "manually" counts as a hack.
trusted_official_docs
CPython Docs
This is expected. Notice that pure-Python modules behave the same way: it is a part of how Python works. The goal is to make extension modules safe at the C level, not to make hacks behave intuitively. Mutating ``sys.modules`` "manually" counts as a hack.
This is expected. Notice that pure-Python modules behave the same way: it is a part of how Python works. The goal is to make extension modules safe at the C level, not to make hacks behave intuitively. Mutating ``sys.modules`` "manually" counts as a hack.
python, official-docs, cpython, P0
Local_Trusted_Corpus
dbecefa7-8c3a-481e-b341-312ce68f914a
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,872
supabase-export-v2
923720026456af6b
static int my_traverse(PyObject *self, visitproc visit, void *arg) { if (Py_Version >= 0x03090000) { Py_VISIT(Py_TYPE(self)); } return 0; } Unfortunately, :c:data:`Py_Version` was only added in Python 3.11. As a replacement, use:
trusted_official_docs
CPython Docs
static int my_traverse(PyObject *self, visitproc visit, void *arg) { if (Py_Version >= 0x03090000) { Py_VISIT(Py_TYPE(self)); } return 0; } Unfortunately, :c:data:`Py_Version` was only added in Python 3.11. As a replacement, use:
static int my_traverse(PyObject *self, visitproc visit, void *arg) { if (Py_Version >= 0x03090000) { Py_VISIT(Py_TYPE(self)); } return 0; } Unfortunately, :c:data:`Py_Version` was only added in Python 3.11. As a replacement, use:
python, official-docs, cpython, P0
Local_Trusted_Corpus
e2f9ab21-bff4-4ea5-85bb-9875c09c7cc5
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,812
supabase-export-v2
cbf9418c8fb1186a
when it's freed. In this regard, a module is just like any other :c:expr:`PyObject *`; there are no "on interpreter shutdown" hooks to think—or forget—about. Note that there are use cases for different kinds of "globals": per-process, per-interpreter, per-thread or per-task state. With per-module state as the default, ...
trusted_official_docs
CPython Docs
when it's freed. In this regard, a module is just like any other :c:expr:`PyObject *`; there are no "on interpreter shutdown" hooks to think—or forget—about. Note that there are use cases for different kinds of "globals": per-process, per-interpreter, per-thread or per-task state. With per-module state as the default, ...
when it's freed. In this regard, a module is just like any other :c:expr:`PyObject *`; there are no "on interpreter shutdown" hooks to think—or forget—about. Note that there are use cases for different kinds of "globals": per-process, per-interpreter, per-thread or per-task state. With per-module state as the default, ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
e436722c-1480-4b7f-a3d7-4cf54cacf3fb
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,900
supabase-export-v2
4de2b6c9a2d575fb
you have a type object defined with :c:func:`PyType_FromModuleAndSpec`, you can call :c:func:`PyType_GetModule` to get the associated module, and then :c:func:`PyModule_GetState` to get the module's state. To save a some tedious error-handling boilerplate code, you can combine these two steps with :c:func:`PyType_GetMo...
trusted_official_docs
CPython Docs
you have a type object defined with :c:func:`PyType_FromModuleAndSpec`, you can call :c:func:`PyType_GetModule` to get the associated module, and then :c:func:`PyModule_GetState` to get the module's state. To save a some tedious error-handling boilerplate code, you can combine these two steps with :c:func:`PyType_GetMo...
you have a type object defined with :c:func:`PyType_FromModuleAndSpec`, you can call :c:func:`PyType_GetModule` to get the associated module, and then :c:func:`PyModule_GetState` to get the module's state. To save a some tedious error-handling boilerplate code, you can combine these two steps with :c:func:`PyType_GetMo...
python, official-docs, cpython, P0
Local_Trusted_Corpus
e7788148-4089-4c78-8c3f-4fe6c058801c
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,864
supabase-export-v2
42fde991e2be5876
Garbage-Collection Protocol --------------------------- Instances of heap types hold a reference to their type. This ensures that the type isn't destroyed before all its instances are, but may result in reference cycles that need to be broken by the garbage collector.
trusted_official_docs
CPython Docs
Garbage-Collection Protocol --------------------------- Instances of heap types hold a reference to their type. This ensures that the type isn't destroyed before all its instances are, but may result in reference cycles that need to be broken by the garbage collector.
Garbage-Collection Protocol --------------------------- Instances of heap types hold a reference to their type. This ensures that the type isn't destroyed before all its instances are, but may result in reference cycles that need to be broken by the garbage collector.
python, official-docs, cpython, P0
Local_Trusted_Corpus
e899e097-1d38-43e8-8f9e-9d61d1882fdb
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,833
supabase-export-v2
d6ec790cef40f5e4
To use per-module state, use :ref:`multi-phase extension module initialization <multi-phase-initialization>`. This signals that your module supports multiple interpreters correctly. Set ``PyModuleDef.m_size`` to a positive number to request that many bytes of storage local to the module. Usually, this will be set to th...
trusted_official_docs
CPython Docs
To use per-module state, use :ref:`multi-phase extension module initialization <multi-phase-initialization>`. This signals that your module supports multiple interpreters correctly. Set ``PyModuleDef.m_size`` to a positive number to request that many bytes of storage local to the module. Usually, this will be set to th...
To use per-module state, use :ref:`multi-phase extension module initialization <multi-phase-initialization>`. This signals that your module supports multiple interpreters correctly. Set ``PyModuleDef.m_size`` to a positive number to request that many bytes of storage local to the module. Usually, this will be set to th...
python, official-docs, cpython, P0
Local_Trusted_Corpus
ea7cef99-60bf-43cc-b1d0-f7c9dc9e7dec
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,848
supabase-export-v2
5f2bf3a5a996aac1
PyObject * func(PyObject *module, PyObject *args) { my_struct *state = (my_struct*)PyModule_GetState(module); if (state == NULL) { return NULL; } // ... rest of logic } .. note:: ``PyModule_GetState`` may return ``NULL`` without setting an exception if there is no module state, i.e. ``PyModuleDef.m_size`` was zero. ...
trusted_official_docs
CPython Docs
PyObject * func(PyObject *module, PyObject *args) { my_struct *state = (my_struct*)PyModule_GetState(module); if (state == NULL) { return NULL; } // ... rest of logic } .. note:: ``PyModule_GetState`` may return ``NULL`` without setting an exception if there is no module state, i.e. ``PyModuleDef.m_size`` was zero. ...
PyObject * func(PyObject *module, PyObject *args) { my_struct *state = (my_struct*)PyModule_GetState(module); if (state == NULL) { return NULL; } // ... rest of logic } .. note:: ``PyModule_GetState`` may return ``NULL`` without setting an exception if there is no module state, i.e. ``PyModuleDef.m_size`` was zero. ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
ed027538-75ce-4775-82b0-e0e80267f8ce
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,854
supabase-export-v2
2613d3712e845f80
the type must be converted to a *heap-allocated type*, or *heap type* for short. These correspond more closely to classes created by Python's ``class`` statement. For new modules, using heap types by default is a good rule of thumb.
trusted_official_docs
CPython Docs
the type must be converted to a *heap-allocated type*, or *heap type* for short. These correspond more closely to classes created by Python's ``class`` statement. For new modules, using heap types by default is a good rule of thumb.
the type must be converted to a *heap-allocated type*, or *heap type* for short. These correspond more closely to classes created by Python's ``class`` statement. For new modules, using heap types by default is a good rule of thumb.
python, official-docs, cpython, P0
Local_Trusted_Corpus
f312d9c9-0959-45e1-bb3c-c5856b663108
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,866
supabase-export-v2
8a88ed1060a0aa01
To avoid memory leaks, instances of heap types must implement the garbage collection protocol. That is, heap types should: - Have the :c:macro:`Py_TPFLAGS_HAVE_GC` flag. - Define a traverse function using :c:data:`Py_tp_traverse`, which visits the type (e.g. using ``Py_VISIT(Py_TYPE(self))``).
trusted_official_docs
CPython Docs
To avoid memory leaks, instances of heap types must implement the garbage collection protocol. That is, heap types should: - Have the :c:macro:`Py_TPFLAGS_HAVE_GC` flag. - Define a traverse function using :c:data:`Py_tp_traverse`, which visits the type (e.g. using ``Py_VISIT(Py_TYPE(self))``).
To avoid memory leaks, instances of heap types must implement the garbage collection protocol. That is, heap types should: - Have the :c:macro:`Py_TPFLAGS_HAVE_GC` flag. - Define a traverse function using :c:data:`Py_tp_traverse`, which visits the type (e.g. using ``Py_VISIT(Py_TYPE(self))``).
python, official-docs, cpython, P0
Local_Trusted_Corpus
f4d66a72-8218-4af1-96ea-a73a94b516f3
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,825
supabase-export-v2
71b612decaab384a
The goal is to make extension modules safe at the C level, not to make hacks behave intuitively. Mutating ``sys.modules`` "manually" counts as a hack. Making Modules Safe with Multiple Interpreters ==============================================
trusted_official_docs
CPython Docs
The goal is to make extension modules safe at the C level, not to make hacks behave intuitively. Mutating ``sys.modules`` "manually" counts as a hack. Making Modules Safe with Multiple Interpreters ==============================================
The goal is to make extension modules safe at the C level, not to make hacks behave intuitively. Mutating ``sys.modules`` "manually" counts as a hack. Making Modules Safe with Multiple Interpreters ==============================================
python, official-docs, cpython, P0
Local_Trusted_Corpus
f580fbab-d9be-4570-8cbd-c3efe9db78ab
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,862
supabase-export-v2
b321f2576d29232e
Other functions, like :c:func:`PyType_FromSpec`, can also create heap types, but :c:func:`PyType_FromModuleAndSpec` associates the module with the class, allowing access to the module state from methods. The class should generally be stored in *both* the module state (for safe access from C) and the module's ``__dict__...
trusted_official_docs
CPython Docs
Other functions, like :c:func:`PyType_FromSpec`, can also create heap types, but :c:func:`PyType_FromModuleAndSpec` associates the module with the class, allowing access to the module state from methods. The class should generally be stored in *both* the module state (for safe access from C) and the module's ``__dict__...
Other functions, like :c:func:`PyType_FromSpec`, can also create heap types, but :c:func:`PyType_FromModuleAndSpec` associates the module with the class, allowing access to the module state from methods. The class should generally be stored in *both* the module state (for safe access from C) and the module's ``__dict__...
python, official-docs, cpython, P0
Local_Trusted_Corpus
fc3ebbe8-3c79-44cf-9f56-e4576c85f465
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,852
supabase-export-v2
084f6679a44bd391
they own or access. To limit the possible issues, static types are immutable at the Python level: for example, you can't set ``str.myattribute = 123``. .. impl-detail:: Sharing truly immutable objects between interpreters is fine, as long as they don't provide access to mutable objects. However, in CPython, every Pyt...
trusted_official_docs
CPython Docs
they own or access. To limit the possible issues, static types are immutable at the Python level: for example, you can't set ``str.myattribute = 123``. .. impl-detail:: Sharing truly immutable objects between interpreters is fine, as long as they don't provide access to mutable objects. However, in CPython, every Pyt...
they own or access. To limit the possible issues, static types are immutable at the Python level: for example, you can't set ``str.myattribute = 123``. .. impl-detail:: Sharing truly immutable objects between interpreters is fine, as long as they don't provide access to mutable objects. However, in CPython, every Pyt...
python, official-docs, cpython, P0
Local_Trusted_Corpus
fe5c37d1-f68f-4b20-8164-4d2c2acea3f3
CPython Docs
file://datasets/cpython/Doc/howto/isolating-extensions.rst
unknown
bd76972e-a00c-40c6-8eea-2a893a040e88
57,808
supabase-export-v2
ec0f956587fee290
is very easy to introduce edge cases that lead to crashes when a module is loaded in more than one interpreter in the same process. Unfortunately, *per-interpreter* state is not easy to achieve. Extension authors tend to not keep multiple interpreters in mind when developing, and it is currently cumbersome to test the ...
trusted_official_docs
CPython Docs
is very easy to introduce edge cases that lead to crashes when a module is loaded in more than one interpreter in the same process. Unfortunately, *per-interpreter* state is not easy to achieve. Extension authors tend to not keep multiple interpreters in mind when developing, and it is currently cumbersome to test the ...
is very easy to introduce edge cases that lead to crashes when a module is loaded in more than one interpreter in the same process. Unfortunately, *per-interpreter* state is not easy to achieve. Extension authors tend to not keep multiple interpreters in mind when developing, and it is currently cumbersome to test the ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
01231588-fb2a-4038-bc48-07b7833c40f2
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,060
supabase-export-v2
acf2d13280e61a29
pass >>> class D(object): pass >>> class E(object): pass >>> class K1(A,B,C): pass >>> class K2(D,B,E): pass >>> class K3(D,A): pass >>> class Z(K1,K2,K3): pass Here are the linearizations according to the C3 MRO (the reader should verify these linearizations as an exercise and draw the inheritance diagram ;-) ::
trusted_official_docs
CPython Docs
pass >>> class D(object): pass >>> class E(object): pass >>> class K1(A,B,C): pass >>> class K2(D,B,E): pass >>> class K3(D,A): pass >>> class Z(K1,K2,K3): pass Here are the linearizations according to the C3 MRO (the reader should verify these linearizations as an exercise and draw the inheritance diagram ;-) ::
pass >>> class D(object): pass >>> class E(object): pass >>> class K1(A,B,C): pass >>> class K2(D,B,E): pass >>> class K3(D,A): pass >>> class Z(K1,K2,K3): pass Here are the linearizations according to the C3 MRO (the reader should verify these linearizations as an exercise and draw the inheritance diagram ;-) ::
python, official-docs, cpython, P0
Local_Trusted_Corpus
01569f60-defd-4487-b42b-5a65ae71e911
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,050
supabase-export-v2
93ab1f9e9d0607db
issue of monotonicity. My goal is to show that neither the MRO for classic classes nor that for Python 2.2 new style classes is monotonic. To prove that the MRO for classic classes is non-monotonic is rather trivial, it is enough to look at the diamond diagram:
trusted_official_docs
CPython Docs
issue of monotonicity. My goal is to show that neither the MRO for classic classes nor that for Python 2.2 new style classes is monotonic. To prove that the MRO for classic classes is non-monotonic is rather trivial, it is enough to look at the diamond diagram:
issue of monotonicity. My goal is to show that neither the MRO for classic classes nor that for Python 2.2 new style classes is monotonic. To prove that the MRO for classic classes is non-monotonic is rather trivial, it is enough to look at the diamond diagram:
python, official-docs, cpython, P0
Local_Trusted_Corpus
057a1a60-d778-4d7c-9141-65dce9f2d44c
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,066
supabase-export-v2
6b154b61d96c416a
The end ------- This section is for the impatient reader, who skipped all the previous sections and jumped immediately to the end. This section is for the lazy programmer too, who didn't want to exercise her/his brain. Finally, it is for the programmer with some hubris, otherwise s/he would not be reading a paper on th...
trusted_official_docs
CPython Docs
The end ------- This section is for the impatient reader, who skipped all the previous sections and jumped immediately to the end. This section is for the lazy programmer too, who didn't want to exercise her/his brain. Finally, it is for the programmer with some hubris, otherwise s/he would not be reading a paper on th...
The end ------- This section is for the impatient reader, who skipped all the previous sections and jumped immediately to the end. This section is for the lazy programmer too, who didn't want to exercise her/his brain. Finally, it is for the programmer with some hubris, otherwise s/he would not be reading a paper on th...
python, official-docs, cpython, P0
Local_Trusted_Corpus
096264fc-2535-45b2-825d-cb26077790cb
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,039
supabase-export-v2
231acf07014a8f81
cannot be computed, because F is in the tail of EFO and E is in the tail of FE. The real solution is to design a non-ambiguous hierarchy, i.e. to derive G from E and F (the more specific first) and not from F and E; in this case the MRO is GEF without any doubt.
trusted_official_docs
CPython Docs
cannot be computed, because F is in the tail of EFO and E is in the tail of FE. The real solution is to design a non-ambiguous hierarchy, i.e. to derive G from E and F (the more specific first) and not from F and E; in this case the MRO is GEF without any doubt.
cannot be computed, because F is in the tail of EFO and E is in the tail of FE. The real solution is to design a non-ambiguous hierarchy, i.e. to derive G from E and F (the more specific first) and not from F and E; in this case the MRO is GEF without any doubt.
python, official-docs, cpython, P0
Local_Trusted_Corpus
0f097bd0-5ef2-44b4-8e44-ba64b2726e40
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
57,963
supabase-export-v2
688edd88b5621c78
>>> O = object >>> class X(O): pass >>> class Y(O): pass >>> class A(X,Y): pass >>> class B(Y,X): pass which can be represented with the following inheritance graph, where I have denoted with O the ``object`` class, which is the beginning of any hierarchy for new style classes:
trusted_official_docs
CPython Docs
>>> O = object >>> class X(O): pass >>> class Y(O): pass >>> class A(X,Y): pass >>> class B(Y,X): pass which can be represented with the following inheritance graph, where I have denoted with O the ``object`` class, which is the beginning of any hierarchy for new style classes:
>>> O = object >>> class X(O): pass >>> class Y(O): pass >>> class A(X,Y): pass >>> class B(Y,X): pass which can be represented with the following inheritance graph, where I have denoted with O the ``object`` class, which is the beginning of any hierarchy for new style classes:
python, official-docs, cpython, P0
Local_Trusted_Corpus
0f5719bb-ce5d-4887-bf6a-7d18091a3b4e
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
57,961
supabase-export-v2
fe3dddad1936961d
linearization. There are cases, in complicated hierarchies, where it is not possible to derive a class such that its linearization respects all the desired properties. Here I give an example of this situation. Consider the hierarchy
trusted_official_docs
CPython Docs
linearization. There are cases, in complicated hierarchies, where it is not possible to derive a class such that its linearization respects all the desired properties. Here I give an example of this situation. Consider the hierarchy
linearization. There are cases, in complicated hierarchies, where it is not possible to derive a class such that its linearization respects all the desired properties. Here I give an example of this situation. Consider the hierarchy
python, official-docs, cpython, P0
Local_Trusted_Corpus
1037f455-59ae-49c2-8550-f04273fe37b7
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,058
supabase-export-v2
890830802d982a7b
diamonds for classic classes. But all new style classes inherit from ``object``, therefore diamonds are unavoidable and inconsistencies shows up in every multiple inheritance graph. The MRO of Python 2.2 makes breaking monotonicity difficult, but not impossible. The following example, originally provided by Samuele Ped...
trusted_official_docs
CPython Docs
diamonds for classic classes. But all new style classes inherit from ``object``, therefore diamonds are unavoidable and inconsistencies shows up in every multiple inheritance graph. The MRO of Python 2.2 makes breaking monotonicity difficult, but not impossible. The following example, originally provided by Samuele Ped...
diamonds for classic classes. But all new style classes inherit from ``object``, therefore diamonds are unavoidable and inconsistencies shows up in every multiple inheritance graph. The MRO of Python 2.2 makes breaking monotonicity difficult, but not impossible. The following example, originally provided by Samuele Ped...
python, official-docs, cpython, P0
Local_Trusted_Corpus
12d2ec9d-7603-46fa-9437-b9a515ed1b5a
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,006
supabase-export-v2
e4c062c492a31a5f
Now we can compute:: L[A] = A + merge(BDEO,CDFO,BC) = A + B + merge(DEO,CDFO,C) = A + B + C + merge(DEO,DFO) = A + B + C + D + merge(EO,FO) = A + B + C + D + E + merge(O,FO) = A + B + C + D + E + F + merge(O,O) = A B C D E F O
trusted_official_docs
CPython Docs
Now we can compute:: L[A] = A + merge(BDEO,CDFO,BC) = A + B + merge(DEO,CDFO,C) = A + B + C + merge(DEO,DFO) = A + B + C + D + merge(EO,FO) = A + B + C + D + E + merge(O,FO) = A + B + C + D + E + F + merge(O,O) = A B C D E F O
Now we can compute:: L[A] = A + merge(BDEO,CDFO,BC) = A + B + merge(DEO,CDFO,C) = A + B + C + merge(DEO,DFO) = A + B + C + D + merge(EO,FO) = A + B + C + D + E + merge(O,FO) = A + B + C + D + E + F + merge(O,O) = A B C D E F O
python, official-docs, cpython, P0
Local_Trusted_Corpus
13f5d4e6-047f-4a71-9c7d-625cef741091
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,047
supabase-export-v2
81b092f2e49a3e3a
Finally, I would like to point out two lessons we have learned from this example: 1. despite the name, the MRO determines the resolution order of attributes, not only of methods;
trusted_official_docs
CPython Docs
Finally, I would like to point out two lessons we have learned from this example: 1. despite the name, the MRO determines the resolution order of attributes, not only of methods;
Finally, I would like to point out two lessons we have learned from this example: 1. despite the name, the MRO determines the resolution order of attributes, not only of methods;
python, official-docs, cpython, P0
Local_Trusted_Corpus
16960ab4-6ef7-41fc-8464-32b952ebe80b
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
57,966
supabase-export-v2
98ed3838fcd18792
| | | O | | / \ | - X Y / | / | / | / |/ A B \ / ? In this case, it is not possible to derive a new class C from A and B, since X precedes Y in A, but Y precedes X in B, therefore the method resolution order would be ambiguous in C.
trusted_official_docs
CPython Docs
| | | O | | / \ | - X Y / | / | / | / |/ A B \ / ? In this case, it is not possible to derive a new class C from A and B, since X precedes Y in A, but Y precedes X in B, therefore the method resolution order would be ambiguous in C.
| | | O | | / \ | - X Y / | / | / | / |/ A B \ / ? In this case, it is not possible to derive a new class C from A and B, since X precedes Y in A, but Y precedes X in B, therefore the method resolution order would be ambiguous in C.
python, official-docs, cpython, P0
Local_Trusted_Corpus
17e7a558-3678-4fc0-9522-16dd46aaaf99
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
57,979
supabase-export-v2
bf6ef684c5cc4709
Now I can explain how the MRO works in Python 2.3. Consider a class C in a multiple inheritance hierarchy, with C inheriting from the base classes B1, B2, ... , BN. We want to compute the linearization L[C] of the class C. The rule is the following:
trusted_official_docs
CPython Docs
Now I can explain how the MRO works in Python 2.3. Consider a class C in a multiple inheritance hierarchy, with C inheriting from the base classes B1, B2, ... , BN. We want to compute the linearization L[C] of the class C. The rule is the following:
Now I can explain how the MRO works in Python 2.3. Consider a class C in a multiple inheritance hierarchy, with C inheriting from the base classes B1, B2, ... , BN. We want to compute the linearization L[C] of the class C. The rule is the following:
python, official-docs, cpython, P0
Local_Trusted_Corpus
1c5c9276-0b1f-405c-9a8e-d20989fd2054
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,023
supabase-export-v2
33c17967f0789bfc
Bad Method Resolution Orders ---------------------------- A MRO is *bad* when it breaks such fundamental properties as local precedence ordering and monotonicity. In this section, I will show that both the MRO for classic classes and the MRO for new style classes in Python 2.2 are bad.
trusted_official_docs
CPython Docs
Bad Method Resolution Orders ---------------------------- A MRO is *bad* when it breaks such fundamental properties as local precedence ordering and monotonicity. In this section, I will show that both the MRO for classic classes and the MRO for new style classes in Python 2.2 are bad.
Bad Method Resolution Orders ---------------------------- A MRO is *bad* when it breaks such fundamental properties as local precedence ordering and monotonicity. In this section, I will show that both the MRO for classic classes and the MRO for new style classes in Python 2.2 are bad.
python, official-docs, cpython, P0
Local_Trusted_Corpus
1c87a89b-f20b-4fce-b05c-d4624eb9f515
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
57,959
supabase-export-v2
534cf4db711a8050
hierarchies, the construction of the linearization is more cumbersome, since it is more difficult to construct a linearization that respects *local precedence ordering* and *monotonicity*. 5) I will discuss the local precedence ordering later, but I can give the definition of monotonicity here. A MRO is monotonic when...
trusted_official_docs
CPython Docs
hierarchies, the construction of the linearization is more cumbersome, since it is more difficult to construct a linearization that respects *local precedence ordering* and *monotonicity*. 5) I will discuss the local precedence ordering later, but I can give the definition of monotonicity here. A MRO is monotonic when...
hierarchies, the construction of the linearization is more cumbersome, since it is more difficult to construct a linearization that respects *local precedence ordering* and *monotonicity*. 5) I will discuss the local precedence ordering later, but I can give the definition of monotonicity here. A MRO is monotonic when...
python, official-docs, cpython, P0
Local_Trusted_Corpus
1e2b4254-3eeb-4f70-a2c9-188836a9cd5e
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,075
supabase-export-v2
65938dc5ee321711
cand=None #reject candidate else: break if not cand: raise "Inconsistent hierarchy" res.append(cand) for seq in nonemptyseqs: # remove cand if seq[0] == cand: del seq[0] def mro(C): "Compute the class precedence list (mro) according to C3" return merge([[C]]+map(mro,C.__bases__)+[list(C.__bases__)])
trusted_official_docs
CPython Docs
cand=None #reject candidate else: break if not cand: raise "Inconsistent hierarchy" res.append(cand) for seq in nonemptyseqs: # remove cand if seq[0] == cand: del seq[0] def mro(C): "Compute the class precedence list (mro) according to C3" return merge([[C]]+map(mro,C.__bases__)+[list(C.__bases__)])
cand=None #reject candidate else: break if not cand: raise "Inconsistent hierarchy" res.append(cand) for seq in nonemptyseqs: # remove cand if seq[0] == cand: del seq[0] def mro(C): "Compute the class precedence list (mro) according to C3" return merge([[C]]+map(mro,C.__bases__)+[list(C.__bases__)])
python, official-docs, cpython, P0
Local_Trusted_Corpus
212a0dd6-4f60-4244-972e-9229a14cf7c2
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,054
supabase-export-v2
b9ab9b8a5fa8f6eb
One easily discerns the inconsistency:: L[B,P21] = B C # B precedes C : B's methods win L[D,P21] = D A C B C # B follows C : C's methods win!
trusted_official_docs
CPython Docs
One easily discerns the inconsistency:: L[B,P21] = B C # B precedes C : B's methods win L[D,P21] = D A C B C # B follows C : C's methods win!
One easily discerns the inconsistency:: L[B,P21] = B C # B precedes C : B's methods win L[D,P21] = D A C B C # B follows C : C's methods win!
python, official-docs, cpython, P0
Local_Trusted_Corpus
212a665f-5495-46b9-96d4-9353e6b2e470
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,014
supabase-export-v2
0033346395f4e77f
C, which is in the first level of the hierarchy, i.e. E is more specialized than C, even if it is in a higher level. A lazy programmer can obtain the MRO directly from Python 2.2, since in this case it coincides with the Python 2.3 linearization. It is enough to invoke the :meth:`~type.mro` method of class A:
trusted_official_docs
CPython Docs
C, which is in the first level of the hierarchy, i.e. E is more specialized than C, even if it is in a higher level. A lazy programmer can obtain the MRO directly from Python 2.2, since in this case it coincides with the Python 2.3 linearization. It is enough to invoke the :meth:`~type.mro` method of class A:
C, which is in the first level of the hierarchy, i.e. E is more specialized than C, even if it is in a higher level. A lazy programmer can obtain the MRO directly from Python 2.2, since in this case it coincides with the Python 2.3 linearization. It is enough to invoke the :meth:`~type.mro` method of class A:
python, official-docs, cpython, P0
Local_Trusted_Corpus
293a829b-12a8-4af4-aaf8-dacba9842439
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
57,956
supabase-export-v2
7ef4c3db23670764
hierarchy, it is a non-trivial task to specify the order in which methods are overridden, i.e. to specify the order of the ancestors of C. 2) The list of the ancestors of a class C, including the class itself, ordered from the nearest ancestor to the furthest, is called the class precedence list or the *linearization...
trusted_official_docs
CPython Docs
hierarchy, it is a non-trivial task to specify the order in which methods are overridden, i.e. to specify the order of the ancestors of C. 2) The list of the ancestors of a class C, including the class itself, ordered from the nearest ancestor to the furthest, is called the class precedence list or the *linearization...
hierarchy, it is a non-trivial task to specify the order in which methods are overridden, i.e. to specify the order of the ancestors of C. 2) The list of the ancestors of a class C, including the class itself, ordered from the nearest ancestor to the furthest, is called the class precedence list or the *linearization...
python, official-docs, cpython, P0
Local_Trusted_Corpus
2d6e497b-3972-4978-86fd-62fcf3ef0a4b
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,009
supabase-export-v2
52c5c980876fcd15
I leave as an exercise for the reader to compute the linearization for my second example: >>> O = object >>> class F(O): pass >>> class E(O): pass >>> class D(O): pass >>> class C(D,F): pass >>> class B(E,D): pass >>> class A(B,C): pass
trusted_official_docs
CPython Docs
I leave as an exercise for the reader to compute the linearization for my second example: >>> O = object >>> class F(O): pass >>> class E(O): pass >>> class D(O): pass >>> class C(D,F): pass >>> class B(E,D): pass >>> class A(B,C): pass
I leave as an exercise for the reader to compute the linearization for my second example: >>> O = object >>> class F(O): pass >>> class E(O): pass >>> class D(O): pass >>> class C(D,F): pass >>> class B(E,D): pass >>> class A(B,C): pass
python, official-docs, cpython, P0
Local_Trusted_Corpus
3202339e-61ba-4633-92c9-fcf3774b339d
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,010
supabase-export-v2
8aa73e207fe81870
object >>> class F(O): pass >>> class E(O): pass >>> class D(O): pass >>> class C(D,F): pass >>> class B(E,D): pass >>> class A(B,C): pass The only difference with the previous example is the change B(D,E) --> B(E,D); however even such a little modification completely changes the ordering of the hierarchy:
trusted_official_docs
CPython Docs
object >>> class F(O): pass >>> class E(O): pass >>> class D(O): pass >>> class C(D,F): pass >>> class B(E,D): pass >>> class A(B,C): pass The only difference with the previous example is the change B(D,E) --> B(E,D); however even such a little modification completely changes the ordering of the hierarchy:
object >>> class F(O): pass >>> class E(O): pass >>> class D(O): pass >>> class C(D,F): pass >>> class B(E,D): pass >>> class A(B,C): pass The only difference with the previous example is the change B(D,E) --> B(E,D); however even such a little modification completely changes the ordering of the hierarchy:
python, official-docs, cpython, P0
Local_Trusted_Corpus
33b765d6-1037-4007-b53f-1ccee830df2c
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,013
supabase-export-v2
93ac2518e7985b74
--- Level 1 1 | B | | C | 3 --- --- \ / \ / --- Level 0 0 | A | --- Notice that the class E, which is in the second level of the hierarchy, precedes the class C, which is in the first level of the hierarchy, i.e. E is more specialized than C, even if it is in a higher level.
trusted_official_docs
CPython Docs
--- Level 1 1 | B | | C | 3 --- --- \ / \ / --- Level 0 0 | A | --- Notice that the class E, which is in the second level of the hierarchy, precedes the class C, which is in the first level of the hierarchy, i.e. E is more specialized than C, even if it is in a higher level.
--- Level 1 1 | B | | C | 3 --- --- \ / \ / --- Level 0 0 | A | --- Notice that the class E, which is in the second level of the hierarchy, precedes the class C, which is in the first level of the hierarchy, i.e. E is more specialized than C, even if it is in a higher level.
python, official-docs, cpython, P0
Local_Trusted_Corpus
3938268b-24d9-4380-a417-1f8dcc9a6415
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
57,951
supabase-export-v2
df81bb3602c2df44
lispers [#]_. The present paper gives a (hopefully) readable discussion of the C3 algorithm for Pythonistas who want to understand the reasons for the change. First of all, let me point out that what I am going to say only applies to the *new style classes* introduced in Python 2.2: *classic classes* maintain their old...
trusted_official_docs
CPython Docs
lispers [#]_. The present paper gives a (hopefully) readable discussion of the C3 algorithm for Pythonistas who want to understand the reasons for the change. First of all, let me point out that what I am going to say only applies to the *new style classes* introduced in Python 2.2: *classic classes* maintain their old...
lispers [#]_. The present paper gives a (hopefully) readable discussion of the C3 algorithm for Pythonistas who want to understand the reasons for the change. First of all, let me point out that what I am going to say only applies to the *new style classes* introduced in Python 2.2: *classic classes* maintain their old...
python, official-docs, cpython, P0
Local_Trusted_Corpus
448b917a-2bf3-4b75-ba60-bb2e86cbe4a9
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,015
supabase-export-v2
4a0fd5a657175ab6
from Python 2.2, since in this case it coincides with the Python 2.3 linearization. It is enough to invoke the :meth:`~type.mro` method of class A: >>> A.mro() # doctest: +NORMALIZE_WHITESPACE [<class 'A'>, <class 'B'>, <class 'E'>, <class 'C'>, <class 'D'>, <class 'F'>, <class 'object'>]
trusted_official_docs
CPython Docs
from Python 2.2, since in this case it coincides with the Python 2.3 linearization. It is enough to invoke the :meth:`~type.mro` method of class A: >>> A.mro() # doctest: +NORMALIZE_WHITESPACE [<class 'A'>, <class 'B'>, <class 'E'>, <class 'C'>, <class 'D'>, <class 'F'>, <class 'object'>]
from Python 2.2, since in this case it coincides with the Python 2.3 linearization. It is enough to invoke the :meth:`~type.mro` method of class A: >>> A.mro() # doctest: +NORMALIZE_WHITESPACE [<class 'A'>, <class 'B'>, <class 'E'>, <class 'C'>, <class 'D'>, <class 'F'>, <class 'object'>]
python, official-docs, cpython, P0
Local_Trusted_Corpus
45dec1e1-1e4f-4668-b127-0b52ff9d03f9
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,029
supabase-export-v2
79b103499b40a21e
(buy eggs or spam ?) We see that class G inherits from F and E, with F *before* E: therefore we would expect the attribute *G.remember2buy* to be inherited by *F.remember2buy* and not by *E.remember2buy*: nevertheless Python 2.2 gives
trusted_official_docs
CPython Docs
(buy eggs or spam ?) We see that class G inherits from F and E, with F *before* E: therefore we would expect the attribute *G.remember2buy* to be inherited by *F.remember2buy* and not by *E.remember2buy*: nevertheless Python 2.2 gives
(buy eggs or spam ?) We see that class G inherits from F and E, with F *before* E: therefore we would expect the attribute *G.remember2buy* to be inherited by *F.remember2buy* and not by *E.remember2buy*: nevertheless Python 2.2 gives
python, official-docs, cpython, P0
Local_Trusted_Corpus
4857e495-7a58-4ac1-a74d-6a4c2043b2aa
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
57,955
supabase-export-v2
5feba0c01872b4c2
Let me begin with some basic definitions. 1) Given a class C in a complicated multiple inheritance hierarchy, it is a non-trivial task to specify the order in which methods are overridden, i.e. to specify the order of the ancestors of C.
trusted_official_docs
CPython Docs
Let me begin with some basic definitions. 1) Given a class C in a complicated multiple inheritance hierarchy, it is a non-trivial task to specify the order in which methods are overridden, i.e. to specify the order of the ancestors of C.
Let me begin with some basic definitions. 1) Given a class C in a complicated multiple inheritance hierarchy, it is a non-trivial task to specify the order in which methods are overridden, i.e. to specify the order of the ancestors of C.
python, official-docs, cpython, P0
Local_Trusted_Corpus
48d4a45c-3d08-4433-9750-6db876b513b4
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,049
supabase-export-v2
01b69c69f072f09d
2. the default food for Pythonistas is spam ! (but you already knew that ;-) Having discussed the issue of local precedence ordering, let me now consider the issue of monotonicity. My goal is to show that neither the MRO for classic classes nor that for Python 2.2 new style classes is monotonic.
trusted_official_docs
CPython Docs
2. the default food for Pythonistas is spam ! (but you already knew that ;-) Having discussed the issue of local precedence ordering, let me now consider the issue of monotonicity. My goal is to show that neither the MRO for classic classes nor that for Python 2.2 new style classes is monotonic.
2. the default food for Pythonistas is spam ! (but you already knew that ;-) Having discussed the issue of local precedence ordering, let me now consider the issue of monotonicity. My goal is to show that neither the MRO for classic classes nor that for Python 2.2 new style classes is monotonic.
python, official-docs, cpython, P0
Local_Trusted_Corpus
4d5395b1-c683-4427-939b-3e33b1e43efc
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,072
supabase-export-v2
301d97534e622806
ex_5: "My first example" class O: pass class F(O): pass class E(O): pass class D(O): pass class C(D,F): pass class B(D,E): pass class A(B,C): pass class ex_6: "My second example" class O: pass class F(O): pass class E(O): pass class D(O): pass class C(D,F): pass class B(E,D): pass class A(B,C): pass
trusted_official_docs
CPython Docs
ex_5: "My first example" class O: pass class F(O): pass class E(O): pass class D(O): pass class C(D,F): pass class B(D,E): pass class A(B,C): pass class ex_6: "My second example" class O: pass class F(O): pass class E(O): pass class D(O): pass class C(D,F): pass class B(E,D): pass class A(B,C): pass
ex_5: "My first example" class O: pass class F(O): pass class E(O): pass class D(O): pass class C(D,F): pass class B(D,E): pass class A(B,C): pass class ex_6: "My second example" class O: pass class F(O): pass class E(O): pass class D(O): pass class C(D,F): pass class B(E,D): pass class A(B,C): pass
python, official-docs, cpython, P0
Local_Trusted_Corpus
50832e64-4da8-4e08-821c-e3e820d3ef33
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
57,947
supabase-export-v2
5ae622713ca758b9
Acknowledgments: *All the people of the Python mailing list who sent me their support. Paul Foley who pointed out various imprecisions and made me to add the part on local precedence ordering. David Goodger for help with the formatting in reStructuredText. David Mertz for help with the editing. Finally, Guido van Ros...
trusted_official_docs
CPython Docs
Acknowledgments: *All the people of the Python mailing list who sent me their support. Paul Foley who pointed out various imprecisions and made me to add the part on local precedence ordering. David Goodger for help with the formatting in reStructuredText. David Mertz for help with the editing. Finally, Guido van Ros...
Acknowledgments: *All the people of the Python mailing list who sent me their support. Paul Foley who pointed out various imprecisions and made me to add the part on local precedence ordering. David Goodger for help with the formatting in reStructuredText. David Mertz for help with the editing. Finally, Guido van Ros...
python, official-docs, cpython, P0
Local_Trusted_Corpus
51a758f1-c690-4359-ad64-d32a51392af2
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,022
supabase-export-v2
bfc868b38dcf802e
of XYO: therefore there are no good heads and the C3 algorithm stops. Python 2.3 raises an error and refuses to create the class C. Bad Method Resolution Orders ----------------------------
trusted_official_docs
CPython Docs
of XYO: therefore there are no good heads and the C3 algorithm stops. Python 2.3 raises an error and refuses to create the class C. Bad Method Resolution Orders ----------------------------
of XYO: therefore there are no good heads and the C3 algorithm stops. Python 2.3 raises an error and refuses to create the class C. Bad Method Resolution Orders ----------------------------
python, official-docs, cpython, P0
Local_Trusted_Corpus
546d07da-2fad-4502-8e1d-1436bf665687
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
57,960
supabase-export-v2
83996696ea3ed4d5
of deriving a new class could change the resolution order of methods, potentially introducing very subtle bugs. Examples where this happens will be shown later. 6) Not all classes admit a linearization. There are cases, in complicated hierarchies, where it is not possible to derive a class such that its linearization...
trusted_official_docs
CPython Docs
of deriving a new class could change the resolution order of methods, potentially introducing very subtle bugs. Examples where this happens will be shown later. 6) Not all classes admit a linearization. There are cases, in complicated hierarchies, where it is not possible to derive a class such that its linearization...
of deriving a new class could change the resolution order of methods, potentially introducing very subtle bugs. Examples where this happens will be shown later. 6) Not all classes admit a linearization. There are cases, in complicated hierarchies, where it is not possible to derive a class such that its linearization...
python, official-docs, cpython, P0
Local_Trusted_Corpus
55495558-cb24-4177-8c5f-e44f590c3a8d
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,032
supabase-export-v2
a63cf364724142ec
the order in the local precedence list, i.e. the list of the parents of G, is not preserved in the Python 2.2 linearization of G:: L[G,P22]= G E F object # F *follows* E
trusted_official_docs
CPython Docs
the order in the local precedence list, i.e. the list of the parents of G, is not preserved in the Python 2.2 linearization of G:: L[G,P22]= G E F object # F *follows* E
the order in the local precedence list, i.e. the list of the parents of G, is not preserved in the Python 2.2 linearization of G:: L[G,P22]= G E F object # F *follows* E
python, official-docs, cpython, P0
Local_Trusted_Corpus
56455e45-7132-469f-8d3e-0f60908c6d8b
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
57,953
supabase-export-v2
1208a20a31b7dcc6
*Don't be scared!* Moreover, unless you make strong use of multiple inheritance and you have non-trivial hierarchies, you don't need to understand the C3 algorithm, and you can easily skip this paper. On the other hand, if you really want to know how multiple inheritance works, then this paper is for you. The good news...
trusted_official_docs
CPython Docs
*Don't be scared!* Moreover, unless you make strong use of multiple inheritance and you have non-trivial hierarchies, you don't need to understand the C3 algorithm, and you can easily skip this paper. On the other hand, if you really want to know how multiple inheritance works, then this paper is for you. The good news...
*Don't be scared!* Moreover, unless you make strong use of multiple inheritance and you have non-trivial hierarchies, you don't need to understand the C3 algorithm, and you can easily skip this paper. On the other hand, if you really want to know how multiple inheritance works, then this paper is for you. The good news...
python, official-docs, cpython, P0
Local_Trusted_Corpus
56c8ff4d-0d25-4fe9-ba64-765317e16222
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,030
supabase-export-v2
6e5f48901222084e
E, with F *before* E: therefore we would expect the attribute *G.remember2buy* to be inherited by *F.remember2buy* and not by *E.remember2buy*: nevertheless Python 2.2 gives >>> G.remember2buy # doctest: +SKIP 'eggs'
trusted_official_docs
CPython Docs
E, with F *before* E: therefore we would expect the attribute *G.remember2buy* to be inherited by *F.remember2buy* and not by *E.remember2buy*: nevertheless Python 2.2 gives >>> G.remember2buy # doctest: +SKIP 'eggs'
E, with F *before* E: therefore we would expect the attribute *G.remember2buy* to be inherited by *F.remember2buy* and not by *E.remember2buy*: nevertheless Python 2.2 gives >>> G.remember2buy # doctest: +SKIP 'eggs'
python, official-docs, cpython, P0
Local_Trusted_Corpus
5c8bc9ba-0a14-44ae-938a-768475b2d219
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,048
supabase-export-v2
80b49bd3da4cbf7d
1. despite the name, the MRO determines the resolution order of attributes, not only of methods; 2. the default food for Pythonistas is spam ! (but you already knew that ;-)
trusted_official_docs
CPython Docs
1. despite the name, the MRO determines the resolution order of attributes, not only of methods; 2. the default food for Pythonistas is spam ! (but you already knew that ;-)
1. despite the name, the MRO determines the resolution order of attributes, not only of methods; 2. the default food for Pythonistas is spam ! (but you already knew that ;-)
python, official-docs, cpython, P0
Local_Trusted_Corpus
5d197820-1b82-4643-80d4-fefa9f456ee3
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
57,950
supabase-export-v2
8040928cfe34bbe7
*Felix qui potuit rerum cognoscere causas* -- Virgilius Everything started with a post by Samuele Pedroni to the Python development mailing list [#]_. In his post, Samuele showed that the Python 2.2 method resolution order is not monotonic and he proposed to replace it with the C3 method resolution order. Guido agreed ...
trusted_official_docs
CPython Docs
*Felix qui potuit rerum cognoscere causas* -- Virgilius Everything started with a post by Samuele Pedroni to the Python development mailing list [#]_. In his post, Samuele showed that the Python 2.2 method resolution order is not monotonic and he proposed to replace it with the C3 method resolution order. Guido agreed ...
*Felix qui potuit rerum cognoscere causas* -- Virgilius Everything started with a post by Samuele Pedroni to the Python development mailing list [#]_. In his post, Samuele showed that the Python 2.2 method resolution order is not monotonic and he proposed to replace it with the C3 method resolution order. Guido agreed ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
5d7f4668-a7ea-4202-8a32-015a81d808e7
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,042
supabase-export-v2
cf37d48d6f56c991
O | F (spam) / | (eggs) E | \ | G (eggs, no doubt) Python 2.3 forces the programmer to write good hierarchies (or, at least, less error-prone ones).
trusted_official_docs
CPython Docs
O | F (spam) / | (eggs) E | \ | G (eggs, no doubt) Python 2.3 forces the programmer to write good hierarchies (or, at least, less error-prone ones).
O | F (spam) / | (eggs) E | \ | G (eggs, no doubt) Python 2.3 forces the programmer to write good hierarchies (or, at least, less error-prone ones).
python, official-docs, cpython, P0
Local_Trusted_Corpus
5f308936-e9ba-41b5-b02a-bc1c3a8fa9ce
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
57,967
supabase-export-v2
d32448aa1e1ae463
A and B, since X precedes Y in A, but Y precedes X in B, therefore the method resolution order would be ambiguous in C. Python 2.3 raises an exception in this situation (TypeError: MRO conflict among bases Y, X) forbidding the naive programmer from creating ambiguous hierarchies. Python 2.2 instead does not raise an ex...
trusted_official_docs
CPython Docs
A and B, since X precedes Y in A, but Y precedes X in B, therefore the method resolution order would be ambiguous in C. Python 2.3 raises an exception in this situation (TypeError: MRO conflict among bases Y, X) forbidding the naive programmer from creating ambiguous hierarchies. Python 2.2 instead does not raise an ex...
A and B, since X precedes Y in A, but Y precedes X in B, therefore the method resolution order would be ambiguous in C. Python 2.3 raises an exception in this situation (TypeError: MRO conflict among bases Y, X) forbidding the naive programmer from creating ambiguous hierarchies. Python 2.2 instead does not raise an ex...
python, official-docs, cpython, P0
Local_Trusted_Corpus
6125ac59-2c7c-4b79-834f-ee8041fe036c
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,073
supabase-export-v2
338a8f5e8cb92f70
ex_6: "My second example" class O: pass class F(O): pass class E(O): pass class D(O): pass class C(D,F): pass class B(E,D): pass class A(B,C): pass class ex_9: "Difference between Python 2.2 MRO and C3" #From Samuele class O: pass class A(O): pass class B(O): pass class C(O): pass class D(O): pass class E(O): pa...
trusted_official_docs
CPython Docs
ex_6: "My second example" class O: pass class F(O): pass class E(O): pass class D(O): pass class C(D,F): pass class B(E,D): pass class A(B,C): pass class ex_9: "Difference between Python 2.2 MRO and C3" #From Samuele class O: pass class A(O): pass class B(O): pass class C(O): pass class D(O): pass class E(O): pa...
ex_6: "My second example" class O: pass class F(O): pass class E(O): pass class D(O): pass class C(D,F): pass class B(E,D): pass class A(B,C): pass class ex_9: "Difference between Python 2.2 MRO and C3" #From Samuele class O: pass class A(O): pass class B(O): pass class C(O): pass class D(O): pass class E(O): pa...
python, official-docs, cpython, P0
Local_Trusted_Corpus
61a16c9f-cbc8-4c80-a794-c32c51d0b12c
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,033
supabase-export-v2
30430c3e2f7657a8
L[G,P22]= G E F object # F *follows* E One could argue that the reason why F follows E in the Python 2.2 linearization is that F is less specialized than E, since F is the superclass of E; nevertheless the breaking of local precedence ordering is quite non-intuitive and error prone. This is particularly true since it i...
trusted_official_docs
CPython Docs
L[G,P22]= G E F object # F *follows* E One could argue that the reason why F follows E in the Python 2.2 linearization is that F is less specialized than E, since F is the superclass of E; nevertheless the breaking of local precedence ordering is quite non-intuitive and error prone. This is particularly true since it i...
L[G,P22]= G E F object # F *follows* E One could argue that the reason why F follows E in the Python 2.2 linearization is that F is less specialized than E, since F is the superclass of E; nevertheless the breaking of local precedence ordering is quite non-intuitive and error prone. This is particularly true since it i...
python, official-docs, cpython, P0
Local_Trusted_Corpus
63c16eb6-9c82-40a5-b79c-71ec60ea64e4
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
57,986
supabase-export-v2
e9205f08c8898f0e
However, in general one has to compute the merge according to the following prescription: *take the head of the first list, i.e L[B1][0]; if this head is not in the tail of any of the other lists, then add it to the linearization of C and remove it from the lists in the merge, otherwise look at the head of the next ...
trusted_official_docs
CPython Docs
However, in general one has to compute the merge according to the following prescription: *take the head of the first list, i.e L[B1][0]; if this head is not in the tail of any of the other lists, then add it to the linearization of C and remove it from the lists in the merge, otherwise look at the head of the next ...
However, in general one has to compute the merge according to the following prescription: *take the head of the first list, i.e L[B1][0]; if this head is not in the tail of any of the other lists, then add it to the linearization of C and remove it from the lists in the merge, otherwise look at the head of the next ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
6680dd73-d2be-439e-951b-c26d30ed77d0
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,063
supabase-export-v2
1cf0df71fa342788
Python 2.2 gives exactly the same linearizations for A, B, C, D, E, K1, K2 and K3, but a different linearization for Z:: L[Z,P22] = Z K1 K3 A K2 D B C E O
trusted_official_docs
CPython Docs
Python 2.2 gives exactly the same linearizations for A, B, C, D, E, K1, K2 and K3, but a different linearization for Z:: L[Z,P22] = Z K1 K3 A K2 D B C E O
Python 2.2 gives exactly the same linearizations for A, B, C, D, E, K1, K2 and K3, but a different linearization for Z:: L[Z,P22] = Z K1 K3 A K2 D B C E O
python, official-docs, cpython, P0
Local_Trusted_Corpus
671e65ab-50eb-4702-9aa5-ae915d366430
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,001
supabase-export-v2
ebdc8272d886320e
L[B] = B + merge(DO, EO, DE) We see that D is a good head, therefore we take it and we are reduced to compute ``merge(O,EO,E)``. Now O is not a good head, since it is in the tail of the sequence EO. In this case the rule says that we have to skip to the next sequence. Then we see that E is a good head; we take it and w...
trusted_official_docs
CPython Docs
L[B] = B + merge(DO, EO, DE) We see that D is a good head, therefore we take it and we are reduced to compute ``merge(O,EO,E)``. Now O is not a good head, since it is in the tail of the sequence EO. In this case the rule says that we have to skip to the next sequence. Then we see that E is a good head; we take it and w...
L[B] = B + merge(DO, EO, DE) We see that D is a good head, therefore we take it and we are reduced to compute ``merge(O,EO,E)``. Now O is not a good head, since it is in the tail of the sequence EO. In this case the rule says that we have to skip to the next sequence. Then we see that E is a good head; we take it and w...
python, official-docs, cpython, P0
Local_Trusted_Corpus
6956973a-f2b8-4c8a-8e4f-16febeaf0ec7
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,035
supabase-export-v2
4d3acea02f171883
>>> class F: remember2buy='spam' >>> class E(F): remember2buy='eggs' >>> class G(F,E): pass # doctest: +SKIP >>> G.remember2buy # doctest: +SKIP 'spam' In this case the MRO is GFEF and the local precedence ordering is preserved.
trusted_official_docs
CPython Docs
>>> class F: remember2buy='spam' >>> class E(F): remember2buy='eggs' >>> class G(F,E): pass # doctest: +SKIP >>> G.remember2buy # doctest: +SKIP 'spam' In this case the MRO is GFEF and the local precedence ordering is preserved.
>>> class F: remember2buy='spam' >>> class E(F): remember2buy='eggs' >>> class G(F,E): pass # doctest: +SKIP >>> G.remember2buy # doctest: +SKIP 'spam' In this case the MRO is GFEF and the local precedence ordering is preserved.
python, official-docs, cpython, P0
Local_Trusted_Corpus
6adb6b07-5496-4967-8c8b-746d0c82666b
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
57,945
supabase-export-v2
96e5f14eaf5f1ad3
Disclaimer: *I donate this document to the Python Software Foundation, under the Python 2.3 license. As usual in these circumstances, I warn the reader that what follows* should *be correct, but I don't give any warranty. Use it at your own risk and peril!*
trusted_official_docs
CPython Docs
Disclaimer: *I donate this document to the Python Software Foundation, under the Python 2.3 license. As usual in these circumstances, I warn the reader that what follows* should *be correct, but I don't give any warranty. Use it at your own risk and peril!*
Disclaimer: *I donate this document to the Python Software Foundation, under the Python 2.3 license. As usual in these circumstances, I warn the reader that what follows* should *be correct, but I don't give any warranty. Use it at your own risk and peril!*
python, official-docs, cpython, P0
Local_Trusted_Corpus
6bd13621-8b50-4330-a61e-7e8d74a5c41f
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
57,968
supabase-export-v2
92808e75dcae63cb
the naive programmer from creating ambiguous hierarchies. Python 2.2 instead does not raise an exception, but chooses an *ad hoc* ordering (CABXYO in this case). The C3 Method Resolution Order ------------------------------
trusted_official_docs
CPython Docs
the naive programmer from creating ambiguous hierarchies. Python 2.2 instead does not raise an exception, but chooses an *ad hoc* ordering (CABXYO in this case). The C3 Method Resolution Order ------------------------------
the naive programmer from creating ambiguous hierarchies. Python 2.2 instead does not raise an exception, but chooses an *ad hoc* ordering (CABXYO in this case). The C3 Method Resolution Order ------------------------------
python, official-docs, cpython, P0
Local_Trusted_Corpus
6cdf503c-eedd-48f8-b3eb-4df501b7a616
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
57,940
supabase-export-v2
86de57ad9f9c9ad7
.. note:: This is a historical document, provided as an appendix to the official documentation. The Method Resolution Order discussed here was *introduced* in Python 2.3, but it is still used in later versions -- including Python 3.
trusted_official_docs
CPython Docs
.. note:: This is a historical document, provided as an appendix to the official documentation. The Method Resolution Order discussed here was *introduced* in Python 2.3, but it is still used in later versions -- including Python 3.
.. note:: This is a historical document, provided as an appendix to the official documentation. The Method Resolution Order discussed here was *introduced* in Python 2.3, but it is still used in later versions -- including Python 3.
python, official-docs, cpython, P0
Local_Trusted_Corpus
6d21762d-67df-45b7-bb0f-60b4a2799449
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,045
supabase-export-v2
fd0ff7b3f8f4d5a8
class A(object): pass >>> class C(A,A): pass # error Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: duplicate base class A Python 2.2 (both for classic classes and new style classes) in this situation, would not raise any exception.
trusted_official_docs
CPython Docs
class A(object): pass >>> class C(A,A): pass # error Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: duplicate base class A Python 2.2 (both for classic classes and new style classes) in this situation, would not raise any exception.
class A(object): pass >>> class C(A,A): pass # error Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: duplicate base class A Python 2.2 (both for classic classes and new style classes) in this situation, would not raise any exception.
python, official-docs, cpython, P0
Local_Trusted_Corpus
74caa59c-95e5-46ea-b1ab-6e11ce2cd0d6
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,016
supabase-export-v2
e758b1e22016ccb6
>>> A.mro() # doctest: +NORMALIZE_WHITESPACE [<class 'A'>, <class 'B'>, <class 'E'>, <class 'C'>, <class 'D'>, <class 'F'>, <class 'object'>] Finally, let me consider the example discussed in the first section, involving a serious order disagreement. In this case, it is straightforward to compute the linearizations of ...
trusted_official_docs
CPython Docs
>>> A.mro() # doctest: +NORMALIZE_WHITESPACE [<class 'A'>, <class 'B'>, <class 'E'>, <class 'C'>, <class 'D'>, <class 'F'>, <class 'object'>] Finally, let me consider the example discussed in the first section, involving a serious order disagreement. In this case, it is straightforward to compute the linearizations of ...
>>> A.mro() # doctest: +NORMALIZE_WHITESPACE [<class 'A'>, <class 'B'>, <class 'E'>, <class 'C'>, <class 'D'>, <class 'F'>, <class 'object'>] Finally, let me consider the example discussed in the first section, involving a serious order disagreement. In this case, it is straightforward to compute the linearizations of ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
7957aa95-1e32-45bf-99e5-00b08b8382fc
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
57,994
supabase-export-v2
54055785ba92f4ab
object >>> class F(O): pass >>> class E(O): pass >>> class D(O): pass >>> class C(D,F): pass >>> class B(D,E): pass >>> class A(B,C): pass In this case the inheritance graph can be drawn as:
trusted_official_docs
CPython Docs
object >>> class F(O): pass >>> class E(O): pass >>> class D(O): pass >>> class C(D,F): pass >>> class B(D,E): pass >>> class A(B,C): pass In this case the inheritance graph can be drawn as:
object >>> class F(O): pass >>> class E(O): pass >>> class D(O): pass >>> class C(D,F): pass >>> class B(D,E): pass >>> class A(B,C): pass In this case the inheritance graph can be drawn as:
python, official-docs, cpython, P0
Local_Trusted_Corpus
7cb5964f-5ce6-4273-9784-297908ab9c1b
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,043
supabase-export-v2
33c1987e52970f27
Python 2.3 forces the programmer to write good hierarchies (or, at least, less error-prone ones). On a related note, let me point out that the Python 2.3 algorithm is smart enough to recognize obvious mistakes, as the duplication of classes in the list of parents:
trusted_official_docs
CPython Docs
Python 2.3 forces the programmer to write good hierarchies (or, at least, less error-prone ones). On a related note, let me point out that the Python 2.3 algorithm is smart enough to recognize obvious mistakes, as the duplication of classes in the list of parents:
Python 2.3 forces the programmer to write good hierarchies (or, at least, less error-prone ones). On a related note, let me point out that the Python 2.3 algorithm is smart enough to recognize obvious mistakes, as the duplication of classes in the list of parents:
python, official-docs, cpython, P0
Local_Trusted_Corpus
7e6a5faf-b182-4394-981f-6cfacd6d9c48
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
57,980
supabase-export-v2
38aa25172a0a318f
from the base classes B1, B2, ... , BN. We want to compute the linearization L[C] of the class C. The rule is the following: *the linearization of C is the sum of C plus the merge of the linearizations of the parents and the list of the parents.*
trusted_official_docs
CPython Docs
from the base classes B1, B2, ... , BN. We want to compute the linearization L[C] of the class C. The rule is the following: *the linearization of C is the sum of C plus the merge of the linearizations of the parents and the list of the parents.*
from the base classes B1, B2, ... , BN. We want to compute the linearization L[C] of the class C. The rule is the following: *the linearization of C is the sum of C plus the merge of the linearizations of the parents and the list of the parents.*
python, official-docs, cpython, P0
Local_Trusted_Corpus
87632e91-2438-4bc8-8e3d-284a543ea157
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,070
supabase-export-v2
6873e65c088fc6ad
class __metaclass__(type): "All classes are metamagically modified to be nicely printed" __repr__ = lambda cls: cls.__name__ class ex_2: "Serious order disagreement" #From Guido class O: pass class X(O): pass class Y(O): pass class A(X,Y): pass class B(Y,X): pass try: class Z(A,B): pass #creates Z(A,B) in Pytho...
trusted_official_docs
CPython Docs
class __metaclass__(type): "All classes are metamagically modified to be nicely printed" __repr__ = lambda cls: cls.__name__ class ex_2: "Serious order disagreement" #From Guido class O: pass class X(O): pass class Y(O): pass class A(X,Y): pass class B(Y,X): pass try: class Z(A,B): pass #creates Z(A,B) in Pytho...
class __metaclass__(type): "All classes are metamagically modified to be nicely printed" __repr__ = lambda cls: cls.__name__ class ex_2: "Serious order disagreement" #From Guido class O: pass class X(O): pass class Y(O): pass class A(X,Y): pass class B(Y,X): pass try: class Z(A,B): pass #creates Z(A,B) in Pytho...
python, official-docs, cpython, P0
Local_Trusted_Corpus
87af6d05-712f-48b6-9458-989f889f7935
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,036
supabase-export-v2
953a8c7d71c5740c
In this case the MRO is GFEF and the local precedence ordering is preserved. As a general rule, hierarchies such as the previous one should be avoided, since it is unclear if F should override E or vice-versa. Python 2.3 solves the ambiguity by raising an exception in the creation of class G, effectively stopping the p...
trusted_official_docs
CPython Docs
In this case the MRO is GFEF and the local precedence ordering is preserved. As a general rule, hierarchies such as the previous one should be avoided, since it is unclear if F should override E or vice-versa. Python 2.3 solves the ambiguity by raising an exception in the creation of class G, effectively stopping the p...
In this case the MRO is GFEF and the local precedence ordering is preserved. As a general rule, hierarchies such as the previous one should be avoided, since it is unclear if F should override E or vice-versa. Python 2.3 solves the ambiguity by raising an exception in the creation of class G, effectively stopping the p...
python, official-docs, cpython, P0
Local_Trusted_Corpus
8db71b15-408b-4dfb-a5e4-122e57ce1b10
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
57,988
supabase-export-v2
4fc87321284eacc6
the other hand, if the order cannot be preserved (as in the example of serious order disagreement discussed above) then the merge cannot be computed. The computation of the merge is trivial if C has only one parent (single inheritance); in this case::
trusted_official_docs
CPython Docs
the other hand, if the order cannot be preserved (as in the example of serious order disagreement discussed above) then the merge cannot be computed. The computation of the merge is trivial if C has only one parent (single inheritance); in this case::
the other hand, if the order cannot be preserved (as in the example of serious order disagreement discussed above) then the merge cannot be computed. The computation of the merge is trivial if C has only one parent (single inheritance); in this case::
python, official-docs, cpython, P0
Local_Trusted_Corpus
8ea1daa8-db0a-444b-a5ec-3dcc1d02fbe8
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,062
supabase-export-v2
944c54a2c82164c7
C O L[K2]= K2 D B E O L[K3]= K3 D A O L[Z] = Z K1 K2 K3 D A B C E O Python 2.2 gives exactly the same linearizations for A, B, C, D, E, K1, K2 and K3, but a different linearization for Z::
trusted_official_docs
CPython Docs
C O L[K2]= K2 D B E O L[K3]= K3 D A O L[Z] = Z K1 K2 K3 D A B C E O Python 2.2 gives exactly the same linearizations for A, B, C, D, E, K1, K2 and K3, but a different linearization for Z::
C O L[K2]= K2 D B E O L[K3]= K3 D A O L[Z] = Z K1 K2 K3 D A B C E O Python 2.2 gives exactly the same linearizations for A, B, C, D, E, K1, K2 and K3, but a different linearization for Z::
python, official-docs, cpython, P0
Local_Trusted_Corpus
8eb3b4d8-9dc1-4e5d-b80d-923be888df41
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,044
supabase-export-v2
84b23da30d9a23b0
me point out that the Python 2.3 algorithm is smart enough to recognize obvious mistakes, as the duplication of classes in the list of parents: >>> class A(object): pass >>> class C(A,A): pass # error Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: duplicate base class A
trusted_official_docs
CPython Docs
me point out that the Python 2.3 algorithm is smart enough to recognize obvious mistakes, as the duplication of classes in the list of parents: >>> class A(object): pass >>> class C(A,A): pass # error Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: duplicate base class A
me point out that the Python 2.3 algorithm is smart enough to recognize obvious mistakes, as the duplication of classes in the list of parents: >>> class A(object): pass >>> class C(A,A): pass # error Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: duplicate base class A
python, official-docs, cpython, P0
Local_Trusted_Corpus
9179e842-0388-42f5-a573-6ec20eab79a9
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,055
supabase-export-v2
1b86f1ba3d049806
B C # B precedes C : B's methods win L[D,P21] = D A C B C # B follows C : C's methods win! On the other hand, there are no problems with the Python 2.2 and 2.3 MROs, they give both::
trusted_official_docs
CPython Docs
B C # B precedes C : B's methods win L[D,P21] = D A C B C # B follows C : C's methods win! On the other hand, there are no problems with the Python 2.2 and 2.3 MROs, they give both::
B C # B precedes C : B's methods win L[D,P21] = D A C B C # B follows C : C's methods win! On the other hand, there are no problems with the Python 2.2 and 2.3 MROs, they give both::
python, official-docs, cpython, P0
Local_Trusted_Corpus
920c99f5-1268-416f-8bb3-ed309e6bd312
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
57,990
supabase-export-v2
fafa1c3d5472311b
L[C(B)] = C + merge(L[B],B) = C + L[B] However, in the case of multiple inheritance things are more cumbersome and I don't expect you can understand the rule without a couple of examples ;-)
trusted_official_docs
CPython Docs
L[C(B)] = C + merge(L[B],B) = C + L[B] However, in the case of multiple inheritance things are more cumbersome and I don't expect you can understand the rule without a couple of examples ;-)
L[C(B)] = C + merge(L[B],B) = C + L[B] However, in the case of multiple inheritance things are more cumbersome and I don't expect you can understand the rule without a couple of examples ;-)
python, official-docs, cpython, P0
Local_Trusted_Corpus
9246d7f6-cd60-420b-88b4-c507e086d30f
CPython Docs
file://datasets/cpython/Doc/howto/mro.rst
unknown
020978da-c280-437e-9370-184d98469913
58,071
supabase-export-v2
7214264915faef54
A(X,Y): pass class B(Y,X): pass try: class Z(A,B): pass #creates Z(A,B) in Python 2.2 except TypeError: pass # Z(A,B) cannot be created in Python 2.3 class ex_5: "My first example" class O: pass class F(O): pass class E(O): pass class D(O): pass class C(D,F): pass class B(D,E): pass class A(B,C): pass
trusted_official_docs
CPython Docs
A(X,Y): pass class B(Y,X): pass try: class Z(A,B): pass #creates Z(A,B) in Python 2.2 except TypeError: pass # Z(A,B) cannot be created in Python 2.3 class ex_5: "My first example" class O: pass class F(O): pass class E(O): pass class D(O): pass class C(D,F): pass class B(D,E): pass class A(B,C): pass
A(X,Y): pass class B(Y,X): pass try: class Z(A,B): pass #creates Z(A,B) in Python 2.2 except TypeError: pass # Z(A,B) cannot be created in Python 2.3 class ex_5: "My first example" class O: pass class F(O): pass class E(O): pass class D(O): pass class C(D,F): pass class B(D,E): pass class A(B,C): pass
python, official-docs, cpython, P0
Local_Trusted_Corpus