FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-114314: Move types to ctypes_state by vstinner · Pull Request #114316 · python/cpython · GitHub

/ cpython Public

gh-114314: Move types to ctypes_state - #114316

Closed
vstinner wants to merge 3 commits into
python:mainfrom
vstinner:ctypes_state
Closed

gh-114314: Move types to ctypes_state#114316
vstinner wants to merge 3 commits into
python:mainfrom
vstinner:ctypes_state

Conversation

vstinner commented Jan 19, 2024
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

Move types to the ctypes_state structure:

  • PyCArray_Type
  • PyCData_Type
  • PyCFuncPtr_Type
  • PyCPointer_Type
  • Simple_Type

The following macros get an additional state parameter:

  • ArrayObject_Check()
  • CDataObject_Check()
  • CDataObject_CheckExact()
  • PointerObject_Check()
  • PyCFuncPtrObject_Check()

The following function gets an additional state parameter:

  • _PyCData_set()

Move types to the ctypes_state structure:

* PyCArray_Type
* PyCData_Type
* PyCFuncPtr_Type
* PyCPointer_Type
* Simple_Type

The following macros get an additional state parameter:

* ArrayObject_Check()
* CDataObject_Check()
* CDataObject_CheckExact()
* PointerObject_Check()
* PyCFuncPtrObject_Check()

The following function gets an additional state parameter:

* _PyCData_set()

Co-Authored-By: neonene <53406459+neonene@users.noreply.github.com>

Copy link
Copy Markdown
Member Author

This change only prepares the code to convert static types to heap types. It doesn't change the behavior.

It only moves references to types from global variables to the _ctypes state and pass the state to macros and functions using it.

Copy link
Copy Markdown
Member Author

To keep this change as small as possible, I didn't change the following macros to add a new state parameter.

#define PyCSimpleTypeObject_CheckExact(v)       Py_IS_TYPE(v, GLOBAL_STATE()->PyCSimpleType_Type)
#define PyCSimpleTypeObject_Check(v)    PyObject_TypeCheck(v, GLOBAL_STATE()->PyCSimpleType_Type)
#define PyCArrayTypeObject_Check(v)     PyObject_TypeCheck(v, GLOBAL_STATE()->PyCArrayType_Type)
#define PyCPointerTypeObject_Check(v)   PyObject_TypeCheck(v, GLOBAL_STATE()->PyCPointerType_Type)
#define PyCFuncPtrTypeObject_Check(v)   PyObject_TypeCheck(v, GLOBAL_STATE()->PyCFuncPtrType_Type)
#define PyCStructTypeObject_Check(v)    PyObject_TypeCheck(v, GLOBAL_STATE()->PyCStructType_Type)

These macros can be changed afterwards.

Copy link
Copy Markdown
Member Author

cc @encukou @erlend-aasland @neonene

neonene commented Jan 20, 2024

Copy link
Copy Markdown
Contributor

PR #113857, which expects fewer follow-up PRs, can be closed after this is landed.

Copy link
Copy Markdown
Member Author

I merged #113857 instead.

vstinner closed this Jan 22, 2024
vstinner deleted the ctypes_state branch January 22, 2024 13:41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL