I'm not quite sure I understand your ctypes approach perfectly. But I think the difference is: in the Cython version you convert the strings on every function call. In the ctypes version you convert the strings once with `ctypes.c_wchar_p` and then pass the existing object to each function call.
Potentially you could do the same thing in Cython. The easiest way to convert a string to a wchar buffer Python object is probably `array.array('H', s.encode('utf_16'))` or `memoryview(s.encode('utf_16')).cast('H')`. You could then have your functions accept `wchar[::1]` memoryviews (which should match on Windows I think). Alternatively you could just pass the encoded bytes around and cast the pointers, but that's maybe a little less safe.
Although possibly I'm misunderstanding your problem.
--
---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/cython-users/740a8b2d-6ceb-43b8-8078-c2ecd9199bfcn%40googlegroups.com.
My suggestion probably only worthwhile if you reuse the string across a lot of different calls - it doesn't look like you're doing that.
Beyond that I don't really know. The actual creation of a window probably isn't a useful thing to be benchmarking - presumably it's something that happens pretty rarely. But obviously updating the window may be something where you care about the performance.
To view this discussion visit https://groups.google.com/d/msgid/cython-users/3168b35c-3f10-4df4-9442-ddc4abb1103fn%40googlegroups.com.
It probably makes most sense to write it in C3. But that's largely not based on "efficiency":
I suspect you'll be implementing it by calling lower-level OS
functions, and C3 is a cleaner way of doing that.
Cython is largely a way of blurring the Python-C boundary, and
writing faster Python-like code. I'm not sure if that's what
you're doing.
C3 probably produces a general-purpose library while Cython
produces something that can only be used from Python.
To view this discussion visit https://groups.google.com/d/msgid/cython-users/6802d761-b737-4782-9ad1-51f5c94f1b37n%40googlegroups.com.