building shared library from D code to import into cython
Ellery Newcomer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Oct 12 10:21:23 PDT 2014
On Sunday, 12 October 2014 at 16:07:19 UTC, Laeeth Isharc wrote:
> Any thoughts on speed in 2014 of pyd vs using cython to talk
> to D directly via C/C++ interface? I saw this old coment here:
>
pyd is basically just a convenience layer on top of the C
interface. The part that would most likely screw with performance
would be conversion from D objects to python objects and vice
versa since that normally does a value copy. At the time of that
comment, pyd's strategy for arrays was just iterate and convert
each element. Now pyd can take advantage of the buffer protocol
if it is exposed (2.7+), so converting e.g. numpy arrays should
be just a memcopy.
If you want by ref semantics instead of by value, use PydObject
instead of a D type in your function signature. You can also turn
off all conveniences and just use the C api with raw_only
(https://bitbucket.org/ariovistus/pyd/wiki/CeleriD)
More information about the Digitalmars-d-learn
mailing list