-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
Description
Documentation
In ctypes documentation for 3.11 there was this excerpt in ctypes documentation:
ctypes can access values like this with the in_dll() class methods of the type. pythonapi is a predefined symbol giving access to the Python C api:
>>> opt_flag = c_int.in_dll(pythonapi, "Py_OptimizeFlag") >>> print(opt_flag) c_long(0) >>>If the interpreter would have been started with -O, the sample would have printed c_long(1), or c_long(2) if -OO would have been specified.
The example was rewritten for 3.12 to use the - probably more widely understood Py_Version instead:
ctypes can access values like this with the in_dll() class methods of the type. pythonapi is a predefined symbol giving access to the Python C api:
>>> version = ctypes.c_int.in_dll(ctypes.pythonapi, "Py_Version") >>> print(hex(version.value)) 0x30c00a0
However the last paragraph referring to the old example is still present:
If the interpreter would have been started with -O, the sample would have printed c_long(1), or c_long(2) if -OO would have been specified.