D extensions to python, inline in an ipython/jupyter notebook

Laeeth Isharc via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Thu Jul 2 13:02:45 PDT 2015


On Thursday, 2 July 2015 at 18:28:50 UTC, Russel Winder wrote:
> On Tue, 2015-06-30 at 18:20 +0000, John Colvin via Digitalmars-d
> -announce
>  […]
>> 
>> Ditched distutils in favour of dub. This is easier for me to 
>> maintain and fits much better with the rest of the D ecosystem
>
> I am not convinced by this, though cleary my feeling carry no 
> weight in decision making :-)
>
> For building C, and C++ extension (and indeed Chapel ones) it 
> is assumed distutils will be used, allowing for:
>
> 	python3 setup.py build
>
> 	python3 setup.py install
>
> SCons can do this but every one demands distutils. Can dub 
> really replace distutils for installing extensions as well as 
> building them? Will people installing extensions be prepared to 
> switch to a non -standard system? Whilst perhaps they should, 
> they won't. I fear that without a distutils installation, the 
> extension will never be installed outside the development team. 
> It's not the D community that must be convinced, it is the 
> Python one.

As an addendum: not many people prefer to do non system type 
things in C than a higher level language when time is money.  So 
the mindset is you build a C extension to address the worst bits 
where Python's true colours shine through (ie when you are in a 
tight loop within Python interpreter and not spending most of the 
time in its C libraries.  Or writing C glue to connect Python to 
another library.

In my view, D is different.  I would rather write in D than 
Python, and to me it's much better Tor doing serious work.  Even 
for parsing a CSV I prefer it (although one could debate the 
point).  In any case D is not especially slower to write in than 
Python (particularly when you include time spent getting the bugs 
out), and in a decent number of cases it may be more productive.

So why bother with Python at all ?  Better ecosystem for charting 
and exploring data, and an interpreter is better suited generally 
for certain kinds of tasks.  Also in some areas more libraries, 
which can be helpful to get a quick result, so that one can go 
back and do it properly later.

It would be v helpful to have a Datetime conversion from D.  
Looks like there is a macro for converting from ymd in 
datetime.h, so I guess one could just write some code against 
this API in C, D, or Cython and link it in with D so one can 
transfer data structures over more easily.



More information about the Digitalmars-d-announce mailing list