[Python-Dev] cffi in stdlib
Paul Moore
p.f.moore at gmail.com
Thu Feb 28 09:27:25 CET 2013
More information about the Python-Dev mailing list
Thu Feb 28 09:27:25 CET 2013
- Previous message: [Python-Dev] cffi in stdlib
- Next message: [Python-Dev] cffi in stdlib
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 27 February 2013 23:18, Armin Rigo <arigo at tunes.org> wrote: > from cffi import FFI > ffi = FFI() > ffi.cdef(""" > int MessageBox(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType); > """) > lib = ffi.dlopen("USER32.DLL") > lib.MessageBox(ffi.NULL, "Hello, world!", "Title", 0) Yeah, that's loads better than 0.5. Presumably ffi.NULL isn't needed and I can use 0? (After all, 0 and NULL are equivalent in C, so that's not a correctness issue). The auto-conversion of strings is a huge improvement. > That's a slightly unfair example, because in this case it happens to > work with ctypes without specifying the argtypes and the restype. I > would argue that this feature of ctypes is not a good thing: it's > mostly the same as saying "you only need to declare argtypes and > restype if you get nonsense results or segfaults". That's a bit unfair. I'd say "you only need to declare argtypes if you're dealing with things more complex than integers, strings and null pointers". Which means you're fine for a huge proportion of the Windows API. On the other hand, going to the API level and being able to use all the Windows constants without having to look them up (their values aren't documented, so googling doesn't help :-() is a huge plus. Paul.
- Previous message: [Python-Dev] cffi in stdlib
- Next message: [Python-Dev] cffi in stdlib
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list