| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -195,12 +195,14 @@ Type Objects | |||
| 195 | 195 | before initialization) and should be paired with :c:func:`PyObject_Free` in | |
| 196 | 196 | :c:member:`~PyTypeObject.tp_free`. | |
| 197 | 197 | ||
| 198 | + | ||
| 198 | 199 | .. c:function:: PyObject* PyType_GenericNew(PyTypeObject *type, PyObject *args, PyObject *kwds) | |
| 199 | 200 | ||
| 200 | 201 | Generic handler for the :c:member:`~PyTypeObject.tp_new` slot of a type | |
| 201 | 202 | object. Creates a new instance using the type's | |
| 202 | 203 | :c:member:`~PyTypeObject.tp_alloc` slot and returns the resulting object. | |
| 203 | 204 | ||
| 205 | + | ||
| 204 | 206 | .. c:function:: int PyType_Ready(PyTypeObject *type) | |
| 205 | 207 | ||
| 206 | 208 | Finalize a type object. This should be called on all type objects to finish | |
@@ -217,13 +219,15 @@ Type Objects | |||
| 217 | 219 | GC protocol itself by at least implementing the | |
| 218 | 220 | :c:member:`~PyTypeObject.tp_traverse` handle. | |
| 219 | 221 | ||
| 222 | + | ||
| 220 | 223 | .. c:function:: PyObject* PyType_GetName(PyTypeObject *type) | |
| 221 | 224 | ||
| 222 | 225 | Return the type's name. Equivalent to getting the type's | |
| 223 | 226 | :attr:`~type.__name__` attribute. | |
| 224 | 227 | ||
| 225 | 228 | .. versionadded:: 3.11 | |
| 226 | 229 | ||
| 230 | + | ||
| 227 | 231 | .. c:function:: PyObject* PyType_GetQualName(PyTypeObject *type) | |
| 228 | 232 | ||
| 229 | 233 | Return the type's qualified name. Equivalent to getting the | |
@@ -239,13 +243,15 @@ Type Objects | |||
| 239 | 243 | ||
| 240 | 244 | .. versionadded:: 3.13 | |
| 241 | 245 | ||
| 246 | + | ||
| 242 | 247 | .. c:function:: PyObject* PyType_GetModuleName(PyTypeObject *type) | |
| 243 | 248 | ||
| 244 | 249 | Return the type's module name. Equivalent to getting the | |
| 245 | 250 | :attr:`type.__module__` attribute. | |
| 246 | 251 | ||
| 247 | 252 | .. versionadded:: 3.13 | |
| 248 | 253 | ||
| 254 | + | ||
| 249 | 255 | .. c:function:: void* PyType_GetSlot(PyTypeObject *type, int slot) | |
| 250 | 256 | ||
| 251 | 257 | Return the function pointer stored in the given slot. If the | |
@@ -262,6 +268,7 @@ Type Objects | |||
| 262 | 268 | :c:func:`PyType_GetSlot` can now accept all types. | |
| 263 | 269 | Previously, it was limited to :ref:`heap types <heap-types>`. | |
| 264 | 270 | ||
| 271 | + | ||
| 265 | 272 | .. c:function:: PyObject* PyType_GetModule(PyTypeObject *type) | |
| 266 | 273 | ||
| 267 | 274 | Return the module object associated with the given type when the type was | |
@@ -281,6 +288,7 @@ Type Objects | |||
| 281 | 288 | ||
| 282 | 289 | .. versionadded:: 3.9 | |
| 283 | 290 | ||
| 291 | + | ||
| 284 | 292 | .. c:function:: void* PyType_GetModuleState(PyTypeObject *type) | |
| 285 | 293 | ||
| 286 | 294 | Return the state of the module object associated with the given type. | |
@@ -295,6 +303,7 @@ Type Objects | |||
| 295 | 303 | ||
| 296 | 304 | .. versionadded:: 3.9 | |
| 297 | 305 | ||
| 306 | + | ||
| 298 | 307 | .. c:function:: PyObject* PyType_GetModuleByDef(PyTypeObject *type, struct PyModuleDef *def) | |
| 299 | 308 | ||
| 300 | 309 | Find the first superclass whose module was created from | |
@@ -314,6 +323,7 @@ Type Objects | |||
| 314 | 323 | ||
| 315 | 324 | .. versionadded:: 3.11 | |
| 316 | 325 | ||
| 326 | + | ||
| 317 | 327 | .. c:function:: int PyType_GetBaseByToken(PyTypeObject *type, void *token, PyTypeObject **result) | |
| 318 | 328 | ||
| 319 | 329 | Find the first superclass in *type*'s :term:`method resolution order` whose | |
@@ -332,6 +342,7 @@ Type Objects | |||
| 332 | 342 | ||
| 333 | 343 | .. versionadded:: 3.14 | |
| 334 | 344 | ||
| 345 | + | ||
| 335 | 346 | .. c:function:: int PyUnstable_Type_AssignVersionTag(PyTypeObject *type) | |
| 336 | 347 | ||
| 337 | 348 | Attempt to assign a version tag to the given type. | |
@@ -342,6 +353,16 @@ Type Objects | |||
| 342 | 353 | .. versionadded:: 3.12 | |
| 343 | 354 | ||
| 344 | 355 | ||
| 356 | + .. c:function:: int PyType_SUPPORTS_WEAKREFS(PyTypeObject *type) | ||
| 357 | + | ||
| 358 | + Return true if instances of *type* support creating weak references, false | ||
| 359 | + otherwise. This function always succeeds. *type* must not be ``NULL``. | ||
| 360 | + | ||
| 361 | + .. seealso:: | ||
| 362 | + * :ref:`weakrefobjects` | ||
| 363 | + * :py:mod:`weakref` | ||
| 364 | + | ||
| 365 | + | ||
| 345 | 366 | Creating Heap-Allocated Types | |
| 346 | 367 | ............................. | |
| 347 | 368 | ||
@@ -390,6 +411,7 @@ The following functions and structs are used to create | |||
| 390 | 411 | ||
| 391 | 412 | .. versionadded:: 3.12 | |
| 392 | 413 | ||
| 414 | + | ||
| 393 | 415 | .. c:function:: PyObject* PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases) | |
| 394 | 416 | ||
| 395 | 417 | Equivalent to ``PyType_FromMetaclass(NULL, module, spec, bases)``. | |
@@ -416,6 +438,7 @@ The following functions and structs are used to create | |||
| 416 | 438 | Creating classes whose metaclass overrides | |
| 417 | 439 | :c:member:`~PyTypeObject.tp_new` is no longer allowed. | |
| 418 | 440 | ||
| 441 | + | ||
| 419 | 442 | .. c:function:: PyObject* PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases) | |
| 420 | 443 | ||
| 421 | 444 | Equivalent to ``PyType_FromMetaclass(NULL, NULL, spec, bases)``. | |
@@ -437,6 +460,7 @@ The following functions and structs are used to create | |||
| 437 | 460 | Creating classes whose metaclass overrides | |
| 438 | 461 | :c:member:`~PyTypeObject.tp_new` is no longer allowed. | |
| 439 | 462 | ||
| 463 | + | ||
| 440 | 464 | .. c:function:: PyObject* PyType_FromSpec(PyType_Spec *spec) | |
| 441 | 465 | ||
| 442 | 466 | Equivalent to ``PyType_FromMetaclass(NULL, NULL, spec, NULL)``. | |
@@ -457,6 +481,7 @@ The following functions and structs are used to create | |||
| 457 | 481 | Creating classes whose metaclass overrides | |
| 458 | 482 | :c:member:`~PyTypeObject.tp_new` is no longer allowed. | |
| 459 | 483 | ||
| 484 | + | ||
| 460 | 485 | .. c:function:: int PyType_Freeze(PyTypeObject *type) | |
| 461 | 486 | ||
| 462 | 487 | Make a type immutable: set the :c:macro:`Py_TPFLAGS_IMMUTABLETYPE` flag. | |
@@ -628,6 +653,7 @@ The following functions and structs are used to create | |||
| 628 | 653 | * :c:data:`Py_tp_token` (for clarity, prefer :c:data:`Py_TP_USE_SPEC` | |
| 629 | 654 | rather than ``NULL``) | |
| 630 | 655 | ||
| 656 | + | ||
| 631 | 657 | .. c:macro:: Py_tp_token | |
| 632 | 658 | ||
| 633 | 659 | A :c:member:`~PyType_Slot.slot` that records a static memory layout ID | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -45,6 +45,10 @@ as much as it can. | |||
| 45 | 45 | weakly referenceable object, or if *callback* is not callable, ``None``, or | |
| 46 | 46 | ``NULL``, this will return ``NULL`` and raise :exc:`TypeError`. | |
| 47 | 47 | ||
| 48 | + .. seealso:: | ||
| 49 | + :c:func:`PyType_SUPPORTS_WEAKREFS` for checking if *ob* is weakly | ||
| 50 | + referenceable. | ||
| 51 | + | ||
| 48 | 52 | ||
| 49 | 53 | .. c:function:: PyObject* PyWeakref_NewProxy(PyObject *ob, PyObject *callback) | |
| 50 | 54 | ||
@@ -57,6 +61,10 @@ as much as it can. | |||
| 57 | 61 | is not a weakly referenceable object, or if *callback* is not callable, | |
| 58 | 62 | ``None``, or ``NULL``, this will return ``NULL`` and raise :exc:`TypeError`. | |
| 59 | 63 | ||
| 64 | + .. seealso:: | ||
| 65 | + :c:func:`PyType_SUPPORTS_WEAKREFS` for checking if *ob* is weakly | ||
| 66 | + referenceable. | ||
| 67 | + | ||
| 60 | 68 | ||
| 61 | 69 | .. c:function:: int PyWeakref_GetRef(PyObject *ref, PyObject **pobj) | |
| 62 | 70 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments