Skip to content

ctypes: add __ctype_{be,le}__ class attributes#15642

Open
jorenham wants to merge 3 commits intopython:mainfrom
jorenham:ctypes/endian-class-attrs
Open

ctypes: add __ctype_{be,le}__ class attributes#15642
jorenham wants to merge 3 commits intopython:mainfrom
jorenham:ctypes/endian-class-attrs

Conversation

@jorenham
Copy link
Copy Markdown
Contributor

These class attributes are used when swapping endianness:

>>> import ctypes as ct
>>> ct.c_double.__ctype_le__ is ct.c_double.__ctype_be__
False

There should be need to distinguish between these little- and big-endian type flavors in typeshed, because as far as I can tell, their interfaces are statically equivalent.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@jorenham
Copy link
Copy Markdown
Contributor Author

Using a @type_check_only to avoid code duplication seems to confuse mypy, unfortunately.

Also, as noted in python/cpython#148464 (comment), c_longdouble (and c_longdouble_complex) don't have __ctype_{be,le}__ attributes. And unlike c_complex_float and c_complex_double types, it's not clear that these'll gain __ctype_{be,le}__ attributes anytime soon.

@github-actions
Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant