www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Pyd examples or resources for Python 3.x

reply Seamus <seamus corvideon.ie> writes:
Howdy folks

I am new around these parts and looking forward to getting stuck 
into some D development. Really liking it so far, just one some 
questions though... I am working on a project that did not sit 
well with me when I tried it in Python. I need static typing 
(above and beyond MyPy, as nice as that is) and the extra speed 
from D is a bonus.

However, there are some nice libraries in Python I would still 
like to use (Spacy for example) and I have played around with Pyd 
to see if I can get it working with Python 3.x. Unfortunately the 
documentation and examples in the Pyd repo presume more knowledge 
than I have. I have looked around this forum and there are 
tantalising snippets of conversation that suggest Pyd will work 
with some C based extensions of Python... I just cannot get it to 
work myself.

So does anyone have any sample code, pointers or tips on using 
Pyd with something like Spacy? Is this possible, or even 
desirable?

I have a fallback position for now in that I can wrap my Python 
scripts in something like Fire 
(https://google.github.io/python-fire/guide/) and create an 
external process from D, but that seems a bit less efficient. 
Either that or REST services/ZeroMQ middleware, but they all add 
complexity.

Idle speculation and suggestions welcome!


Cheers

Seamus
Jan 19 2023
next sibling parent Sergey <kornburn yandex.ru> writes:
On Friday, 20 January 2023 at 00:39:47 UTC, Seamus wrote:
 Howdy folks
Honestly in my opinion PyD looks kinda abounded. I don’t know how much effort you need to spend to run spaCy. Just to be sure that you’ve seen this documentation https://pyd.readthedocs.io/en/latest/index.html Also probably if you will find C API (as it is written in Cython) it will be possible to make bindings for them using dstep, ctod or ImportC tools. Or maybe it is possible to prepare D bindings like someone did for other C-like languages: https://github.com/d99kris/spacy-cpp https://github.com/AMArostegui/SpacyDotNet
Jan 19 2023
prev sibling parent reply bachmeier <no spam.net> writes:
On Friday, 20 January 2023 at 00:39:47 UTC, Seamus wrote:
 Howdy folks

 I am new around these parts and looking forward to getting 
 stuck into some D development. Really liking it so far, just 
 one some questions though... I am working on a project that did 
 not sit well with me when I tried it in Python. I need static 
 typing (above and beyond MyPy, as nice as that is) and the 
 extra speed from D is a bonus.

 However, there are some nice libraries in Python I would still 
 like to use (Spacy for example) and I have played around with 
 Pyd to see if I can get it working with Python 3.x. 
 Unfortunately the documentation and examples in the Pyd repo 
 presume more knowledge than I have. I have looked around this 
 forum and there are tantalising snippets of conversation that 
 suggest Pyd will work with some C based extensions of Python... 
 I just cannot get it to work myself.

 So does anyone have any sample code, pointers or tips on using 
 Pyd with something like Spacy? Is this possible, or even 
 desirable?

 I have a fallback position for now in that I can wrap my Python 
 scripts in something like Fire 
 (https://google.github.io/python-fire/guide/) and create an 
 external process from D, but that seems a bit less efficient. 
 Either that or REST services/ZeroMQ middleware, but they all 
 add complexity.

 Idle speculation and suggestions welcome!


 Cheers

 Seamus
Have you tried this? https://github.com/symmetryinvestments/autowrap
Jan 19 2023
parent Seamus <seamus corvideon.ie> writes:
Thanks for all the suggestions folks!
I will take a look. Cheers.
Jan 21 2023