Scientific computing in D

Russel Winder via Digitalmars-d digitalmars-d at puremagic.com
Tue Nov 10 02:13:30 PST 2015


On Mon, 2015-11-09 at 19:31 +0000, Márcio Martins via Digitalmars-d
wrote:
> I have been running some MCMC simulations in Python and it's hard 
> to cope with how unbelievably slow it is.
> Takes me almost a minute to run a few hundred thousand samples on 
> my laptop whereas I can run the same simulation with a million 
> samples in under 100ms, on my phone with JavaScript on a browser.

Are you using NumPy with Python, or pure Python? In either case you
will be better served by profiling you code to find out whoch is
actually the performance bottleneck and then doing one of:

1. Use Numba to JIT the Python and achieve native code speed.
2. Replace the Python code with D code using either CFFI or PyD.
3. Replace the Python code with Chapel code using either CFFI or
PyChapel.

You could also use C++ or Rust via CFFI, but I have little experience
using Rust with Python and am trying to avoid C++.

> Then, you spend a minute waiting for the simulation to finish, to 
> find out you had an error in your report code that would have 
> been easily caught with static typing. So annoying...
> 
> Is anyone doing similar stuff with D? Unfortunately, I couldn't 
> find any plotting libraries nor MATLAB-like numerical/stats libs 
> in dub.

No need if you leave the coordination code in Python and then use
Matplotlib, etc. Just put the computational expensive code into Chapel
or D, leave the rest of your code in Python.

> This seems like another area where D could easily pick up 
> momentum with RDMD and perhaps an integration with Jupyter which 
> is becoming very very popular.

Jupyter (née IPython) is only popular in one workflow, creting papers
for people to read and play with the executable code fragments. This is
a big area but only one of many.

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder at ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel at winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20151110/76f42a07/attachment.sig>


More information about the Digitalmars-d mailing list