[Python] How can I tell if a ctypes integer type is big endian?

Discussão em 'Python' iniciado por Stack, Fevereiro 5, 2025.

  1. Stack

    Stack Membro Participativo

    Consider the following:

    le = ctypes.c_uint32.__ctype_le__
    be = ctypes.c_uint16.__ctype_be__


    How can I write a function is_bigendian(cls) that behaves as you would expect:

    >>> is_bigendian(le)
    False
    >>> is_bigendian(be)
    True


    Does ctypes expose this information somewhere?

    Continue reading...

Compartilhe esta Página