![]() ![]() Pointer to the C implementation int ml_flags ¶įlags bits indicating how the call should be constructed const char * ml_doc ¶ Structure used to describe a method of an extension type. Part of the Stable ABI (including all members). This is a macro used when declaring new types which represent objects This type does not often appear in the Python/C API.Īccess to the members must be done by using the macros This is only used for objects that have some notion of length. This is an extension of PyObject that adds the ob_sizeįield. Members must be done by using the macros Py_REFCNT and To a Python object can be cast to a PyObject *. Nothing is actually declared to be a PyObject, but every pointer Reference count and a pointer to the corresponding type object. In a normal “release” build, it contains only the object’s This is a type whichĬontains the information Python needs to treat a pointer to an object as an (Only some members are part of the stable ABI.)Īll object types are extensions of this type. The definition of all other Python objects. PyObject and PyVarObject types, which are defined, in turn,īy the expansions of some macros also used, whether directly or indirectly, in Of the object’s representation in memory. ![]() This section describes these structures and how theyĪll Python objects ultimately share a small number of fields at the beginning Performance-critical objects (such as numbers).There are a large number of structures which are used in the definition of To participate in the weak reference mechanism without incurring the overhead on One of the goals of Python's weak reference implementation is to allow any type Occurs, tp_iternext should always set an exceptionĪnd return NULL. The exception can yield slightly better performance. StopIteration in addition to returning NULL avoiding May return NULL without setting an exception, or it may set If the iteration has reached the end, tp_iternext Return a new reference to the next object in the iteration, if there is one. Tp_iter handler should return a new reference Iteration, such as file objects) can implement tp_iterīy returning a new reference to themselves - and should also thereforeĪny iterator object should implement both tp_iter Objects which can only be iterated over once (usually due to side effects of ![]() Independent iterators, a new iterator should be created and returned by Here the same guidelinesįor collections (such as lists and tuples) which can support multiple Handler, which must return an iterator object. To the Python _iter_() method, while tp_iternextĬorresponds to the Python _next_() method.Īny iterable object must implement the tp_iter In the case of an error, they should set anĮxception and return NULL. Take exactly one parameter, the instance for which they are being called,Īnd return a new reference. These functions provide support for the iterator protocol. * Iterators */ getiterfunc tp_iter iternextfunc tp_iternext To indicate the presence of a slot, but a slot may still be unfilled.) (The flagīit does not indicate that the slot values are non- NULL. That the slots are present and should be checked by the interpreter. For newer protocols there areĪdditional slots in the main type object, with a flag bit being set to indicate For protocols which depend on several handler routinesįrom the type implementation, the older protocols have been defined as optionalīlocks of handlers referenced by the type object. Other protocols haveīeen added over time. Protocols have been part of Python since the beginning. In particular, the number, mapping, and sequence ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |