Concrete Objects Layer¶
The functions in this chapter are specific to certain Python object types.
Passing them an object of the wrong type is not a good idea; if you receive an
object from a Python program and you are not sure that it has the right type,
you must perform a type check first; for example, to check that an object is a
dictionary, use PyDict_Check(). The chapter is structured like the
“family tree” of Python object types.
Warning
While the functions described in this chapter carefully check the type of the
objects which are passed in, many of them do not check for NULL being passed
instead of a valid object. Allowing NULL to be passed in can cause memory
access violations and immediate termination of the interpreter.
Fundamental Objects¶
This section describes Python type objects and the singleton object None.
- Type Objects
PyTypeObjectPyType_TypePyType_Check()PyType_CheckExact()PyType_ClearCache()PyType_GetFlags()PyType_Modified()PyType_HasFeature()PyType_IS_GC()PyType_IsSubtype()PyType_GenericAlloc()PyType_GenericNew()PyType_Ready()PyType_GetSlot()PyType_GetModule()PyType_GetModuleState()- Creating Heap-Allocated Types
- The
NoneObject
Numeric Objects¶
- Integer Objects
PyLongObjectPyLong_TypePyLong_Check()PyLong_CheckExact()PyLong_FromLong()PyLong_FromUnsignedLong()PyLong_FromSsize_t()PyLong_FromSize_t()PyLong_FromLongLong()PyLong_FromUnsignedLongLong()PyLong_FromDouble()PyLong_FromString()PyLong_FromUnicodeObject()PyLong_FromVoidPtr()PyLong_AsLong()PyLong_AsLongAndOverflow()PyLong_AsLongLong()PyLong_AsLongLongAndOverflow()PyLong_AsSsize_t()PyLong_AsUnsignedLong()PyLong_AsSize_t()PyLong_AsUnsignedLongLong()PyLong_AsUnsignedLongMask()PyLong_AsUnsignedLongLongMask()PyLong_AsDouble()PyLong_AsVoidPtr()
- Boolean Objects
- Floating Point Objects
- Complex Number Objects
Sequence Objects¶
Generic operations on sequence objects were discussed in the previous chapter; this section deals with the specific kinds of sequence objects that are intrinsic to the Python language.
- Bytes Objects
PyBytesObjectPyBytes_TypePyBytes_Check()PyBytes_CheckExact()PyBytes_FromString()PyBytes_FromStringAndSize()PyBytes_FromFormat()PyBytes_FromFormatV()PyBytes_FromObject()PyBytes_Size()PyBytes_GET_SIZE()PyBytes_AsString()PyBytes_AS_STRING()PyBytes_AsStringAndSize()PyBytes_Concat()PyBytes_ConcatAndDel()_PyBytes_Resize()
- Byte Array Objects
- Unicode Objects and Codecs
- Unicode Objects
- Unicode Type
Py_UCS4Py_UCS2Py_UCS1Py_UNICODEPyASCIIObjectPyCompactUnicodeObjectPyUnicodeObjectPyUnicode_TypePyUnicode_Check()PyUnicode_CheckExact()PyUnicode_READY()PyUnicode_GET_LENGTH()PyUnicode_1BYTE_DATA()PyUnicode_2BYTE_DATA()PyUnicode_4BYTE_DATA()PyUnicode_WCHAR_KINDPyUnicode_1BYTE_KINDPyUnicode_2BYTE_KINDPyUnicode_4BYTE_KINDPyUnicode_KIND()PyUnicode_DATA()PyUnicode_WRITE()PyUnicode_READ()PyUnicode_READ_CHAR()PyUnicode_MAX_CHAR_VALUE()PyUnicode_GET_SIZE()PyUnicode_GET_DATA_SIZE()PyUnicode_AS_UNICODE()PyUnicode_AS_DATA()PyUnicode_IsIdentifier()
- Unicode Character Properties
Py_UNICODE_ISSPACE()Py_UNICODE_ISLOWER()Py_UNICODE_ISUPPER()Py_UNICODE_ISTITLE()Py_UNICODE_ISLINEBREAK()Py_UNICODE_ISDECIMAL()Py_UNICODE_ISDIGIT()Py_UNICODE_ISNUMERIC()Py_UNICODE_ISALPHA()Py_UNICODE_ISALNUM()Py_UNICODE_ISPRINTABLE()Py_UNICODE_TOLOWER()Py_UNICODE_TOUPPER()Py_UNICODE_TOTITLE()Py_UNICODE_TODECIMAL()Py_UNICODE_TODIGIT()Py_UNICODE_TONUMERIC()Py_UNICODE_IS_SURROGATE()Py_UNICODE_IS_HIGH_SURROGATE()Py_UNICODE_IS_LOW_SURROGATE()Py_UNICODE_JOIN_SURROGATES()
- Creating and accessing Unicode strings
PyUnicode_New()PyUnicode_FromKindAndData()PyUnicode_FromStringAndSize()PyUnicode_FromString()PyUnicode_FromFormat()PyUnicode_FromFormatV()PyUnicode_FromEncodedObject()PyUnicode_GetLength()PyUnicode_CopyCharacters()PyUnicode_Fill()PyUnicode_WriteChar()PyUnicode_ReadChar()PyUnicode_Substring()PyUnicode_AsUCS4()PyUnicode_AsUCS4Copy()
- Deprecated Py_UNICODE APIs
- Locale Encoding
- File System Encoding
- wchar_t Support
- Unicode Type
- Built-in Codecs
- Methods and Slot Functions
PyUnicode_Concat()PyUnicode_Split()PyUnicode_Splitlines()PyUnicode_Join()PyUnicode_Tailmatch()PyUnicode_Find()PyUnicode_FindChar()PyUnicode_Count()PyUnicode_Replace()PyUnicode_Compare()PyUnicode_CompareWithASCIIString()PyUnicode_RichCompare()PyUnicode_Format()PyUnicode_Contains()PyUnicode_InternInPlace()PyUnicode_InternFromString()
- Unicode Objects
- Tuple Objects
- Struct Sequence Objects
- List Objects
Container Objects¶
- Dictionary Objects
PyDictObjectPyDict_TypePyDict_Check()PyDict_CheckExact()PyDict_New()PyDictProxy_New()PyDict_Clear()PyDict_Contains()PyDict_Copy()PyDict_SetItem()PyDict_SetItemString()PyDict_DelItem()PyDict_DelItemString()PyDict_GetItem()PyDict_GetItemWithError()PyDict_GetItemString()PyDict_SetDefault()PyDict_Items()PyDict_Keys()PyDict_Values()PyDict_Size()PyDict_Next()PyDict_Merge()PyDict_Update()PyDict_MergeFromSeq2()
- Set Objects
Function Objects¶
- Function Objects
PyFunctionObjectPyFunction_TypePyFunction_Check()PyFunction_New()PyFunction_NewWithQualName()PyFunction_GetCode()PyFunction_GetGlobals()PyFunction_GetModule()PyFunction_GetDefaults()PyFunction_SetDefaults()PyFunction_GetClosure()PyFunction_SetClosure()PyFunction_GetAnnotations()PyFunction_SetAnnotations()
- Instance Method Objects
- Method Objects
- Cell Objects
- Code Objects
Other Objects¶
- File Objects
- Module Objects
PyModule_TypePyModule_Check()PyModule_CheckExact()PyModule_NewObject()PyModule_New()PyModule_GetDict()PyModule_GetNameObject()PyModule_GetName()PyModule_GetState()PyModule_GetDef()PyModule_GetFilenameObject()PyModule_GetFilename()- Initializing C modules
- Module lookup
- Iterator Objects
- Descriptor Objects
- Slice Objects
- Ellipsis Object
- MemoryView objects
- Weak Reference Objects
- Capsules
- Generator Objects
- Coroutine Objects
- Context Variables Objects
PyContextPyContextVarPyContextTokenPyContext_TypePyContextVar_TypePyContextToken_TypePyContext_CheckExact()PyContextVar_CheckExact()PyContextToken_CheckExact()PyContext_New()PyContext_Copy()PyContext_CopyCurrent()PyContext_Enter()PyContext_Exit()PyContextVar_New()PyContextVar_Get()PyContextVar_Set()PyContextVar_Reset()
- DateTime Objects
PyDateTime_TimeZone_UTCPyDate_Check()PyDate_CheckExact()PyDateTime_Check()PyDateTime_CheckExact()PyTime_Check()PyTime_CheckExact()PyDelta_Check()PyDelta_CheckExact()PyTZInfo_Check()PyTZInfo_CheckExact()PyDate_FromDate()PyDateTime_FromDateAndTime()PyDateTime_FromDateAndTimeAndFold()PyTime_FromTime()PyTime_FromTimeAndFold()PyDelta_FromDSU()PyTimeZone_FromOffset()PyTimeZone_FromOffsetAndName()PyDateTime_GET_YEAR()PyDateTime_GET_MONTH()PyDateTime_GET_DAY()PyDateTime_DATE_GET_HOUR()PyDateTime_DATE_GET_MINUTE()PyDateTime_DATE_GET_SECOND()PyDateTime_DATE_GET_MICROSECOND()PyDateTime_DATE_GET_FOLD()PyDateTime_DATE_GET_TZINFO()PyDateTime_TIME_GET_HOUR()PyDateTime_TIME_GET_MINUTE()PyDateTime_TIME_GET_SECOND()PyDateTime_TIME_GET_MICROSECOND()PyDateTime_TIME_GET_FOLD()PyDateTime_TIME_GET_TZINFO()PyDateTime_DELTA_GET_DAYS()PyDateTime_DELTA_GET_SECONDS()PyDateTime_DELTA_GET_MICROSECONDS()PyDateTime_FromTimestamp()PyDate_FromTimestamp()
- Objects for Type Hinting