(from stdlib-sig) ctypes or struct from an h file

Yuvgoog Greenle ubershmekel at gmail.com
Mon Oct 19 03:55:47 EDT 2009


Ok I see your point that C is ambiguous concerning compiler
implementation. I think #pragma pack should work out the padding issue
but I'm not sure if the floating point issue is solvable.

I don't have an idea for solving that one...

On Sun, Oct 18, 2009 at 11:14 PM, Erik Max Francis <max at alcyone.com> wrote:
> Yuvgoog Greenle wrote:
>>
>> I'd like to clarify the use case.
>>
>> Lets say you're writing a client and a server, one is in python and
>> the other is C. If these 2 programs need to pass binary information
>> between them (lets say over a socket) there are 2 options, it could be
>> nice if you could only write the struct once (either in python or in
>> C) without any Cython or C extension (for portability and ease of
>> development's sake).
>
> It's not as simple as that.  You have to know the binary format layouts
> (say, for floating point numbers) and struct padding that's used (since it
> can be inserted arbitrarily) on the C side of things, not to mention you
> have to arrange the whole the to be put into consistent (network) byte
> order.  Both sides have to take care of this, since if the server and client
> are running on different architectures, there's no guarantees any of these
> things will be the same.
>
> --
> Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
>  San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxfrancis
>  Diplomacy and defense are not substitutes for one another. Either
>   alone would fail. -- John F. Kennedy, 1917-1963
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list