----- Original Message -----
> From: "Terry Reedy" <tjre...@udel.edu>
> To: python-list@python.org
> Sent: Thursday, 18 June, 2015 7:02:16 PM
> Subject: Re: ctypes and byte order
> 
> On 6/18/2015 5:39 AM, Jean-Michel Pichavant wrote:
> 
> > I'm currently writing python code that writes a small binary file
> > to
> > be used by another device which code is written in C. The python
> > code
> > runs on a little endian CPU, and unfortunately, the other device is
> > using a big endian MIPS.
> 
> The struct module is designed for this.  It reads and writes packed
> binary data of various types and sizes in either big or little endian
> order.  It should be easier than ctypes.
> 
> --
> Terry Jan Reedy

Yep, I knew about struct but I did go for ctypes because... I wanted to try it 
and thought it would be a suitable solution (with more capabilities).
Looks like I fooled myself (not in the way ctypes is badly designed, it's just 
not what I needed).

Now I'm left with a dilemma:

My current ctypes code is working (thanks Peter !), but the code is rather 
cumbersome.

1/ don't change it, and wish good luck to my next co-worker looking at the code
2/ rewrite everything with struct
3/ rewrite everything with cffi (Laura's suggestion) which has the awsomeness 
to suppport C code copy/paste. It's still a "C Foreign Function Interface" like 
ctypes and could be overkill


We all know how this ends up...

JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be 
privileged. If you are not the intended recipient, please notify the sender 
immediately and do not disclose the contents to any other person, use it for 
any purpose, or store or copy the information in any medium. Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to