SERVING THE QUANTITATIVE FINANCE COMMUNITY

Cuchulainn
Posts: 60470
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### Re: Python tricks

Each language faction lives in its own Swiss Army Knife world. For some jobs you need a Husqvarna or Stihl.
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik

katastrofa
Posts: 8494
Joined: August 16th, 2007, 5:36 am
Location: Alpha Centauri

### Re: Python tricks

Always with me!
Attachments

Cuchulainn
Posts: 60470
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### Re: Python tricks

Is Numba a magic wand that we can use to speed up the Python code for rbtrees?
How 'universal' is Numba?
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik

ISayMoo
Posts: 2205
Joined: September 30th, 2015, 8:30 pm

### Re: Python tricks

I haven't seen it used very widely. Where I work, if the performance offered by Python with Numpy with Pandas with TensorFlow is not good enough, someone writes the core part in C++ and exposes it to Python via Swig.

Cuchulainn
Posts: 60470
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### Re: Python tricks

I haven't seen it used very widely. Where I work, if the performance offered by Python with Numpy with Pandas with TensorFlow is not good enough, someone writes the core part in C++ and exposes it to Python via Swig.
I am not a compiler builder but I reckon not everything can be optimised by Numba (I suppose a but like C++ 'inline' is not a guarantee that code will be optimised).

SWIG sounds better because you get performance + data interop. I haven't tried it yet; BTW can we call Python from C++ using SWIG. I believe Boost Python can.

I am supervising several MSc students (who know C++ well)  in ML-PDE-risk projects and are realising that C++ libraries e.g. OpenCV does not have the needed functionality. They are suggesting a pure  Keras but a mixed C++/Python might be the best 'middle ground', especially if we can wrap Keras in  a C++ jacket.
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik

Cuchulainn
Posts: 60470
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### Re: Python tricks

#include <boost/python/module.hpp>
#include <boost/python/def.hpp>

char const* greet()
{
return "hello, world";
}

BOOST_PYTHON_MODULE(hello_ext)
{
using namespace boost::python;
def("greet", greet);
This seems to be a common issue..
This code does not build because it cannot find pyconfig.h

Any ideas (Visual Studio 2017 and Python 3.6)?
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik

FaridMoussaoui
Posts: 453
Joined: June 20th, 2008, 10:05 am
Location: Genève, Genf, Ginevra, Geneva

### Re: Python tricks

Well, just install the python development tools. On linux, it is seamless (as usual)
sudo apt-get install python-dev
or it is called "python3-devel" instead of python-dev.

tagoma
Topic Author
Posts: 18276
Joined: February 21st, 2010, 12:58 pm

### Re: Python tricks

Dumb question. are Python36/include/  and  Python36/libs/  (or the like)  in your Includes?

ISayMoo
Posts: 2205
Joined: September 30th, 2015, 8:30 pm

### Re: Python tricks

I haven't seen it used very widely. Where I work, if the performance offered by Python with Numpy with Pandas with TensorFlow is not good enough, someone writes the core part in C++ and exposes it to Python via Swig.
I am not a compiler builder but I reckon not everything can be optimised by Numba (I suppose a but like C++ 'inline' is not a guarantee that code will be optimised).

SWIG sounds better because you get performance + data interop. I haven't tried it yet; BTW can we call Python from C++ using SWIG. I believe Boost Python can.

I am supervising several MSc students (who know C++ well)  in ML-PDE-risk projects and are realising that C++ libraries e.g. OpenCV does not have the needed functionality. They are suggesting a pure  Keras but a mixed C++/Python might be the best 'middle ground', especially if we can wrap Keras in  a C++ jacket.
IMHO if you can do something in 1 language, try doing so. Mixing different languages always introduces additional cognitive and development overhead and makes debugging harder.

Cuchulainn
Posts: 60470
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### Re: Python tricks

If you define good API interfaces it's worth it?

I don't mind since having become accustomed to using NAG libraries and Hollerith cards in the old days.

More recently:

VBA/Excel and C dlls
C# to C++ via C++/CLI

Trump<-> Putin translator (I don't see the former learning po-russki any time soon).
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik

ISayMoo
Posts: 2205
Joined: September 30th, 2015, 8:30 pm

### Re: Python tricks

And how was debugging? I understand if you don't want to talk about it.

katastrofa
Posts: 8494
Joined: August 16th, 2007, 5:36 am
Location: Alpha Centauri

### Re: Python tricks

But you can learn a lot in the process! Who doesn't want to know every-f***-thing about internal representations of floating point numbers!

ISayMoo
Posts: 2205
Joined: September 30th, 2015, 8:30 pm

### Re: Python tricks

That's the fun part!

Cuchulainn
Posts: 60470
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### Re: Python tricks

And how was debugging? I understand if you don't want to talk about it.
https://en.wikipedia.org/wiki/Design_by_contract

Hardware engineers solved this problem some time ago.

A random google
• Faulty requirements definition.
• Client-developer communication failures.
• Deliberate deviations from software requirements.
• Logical design errors.
• Coding errors.
• Non-compliance with documentation and coding instructions.
• Shortcomings of the testing process.
• User interface and procedure errors.
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik

katastrofa
Posts: 8494
Joined: August 16th, 2007, 5:36 am
Location: Alpha Centauri

### Re: Python tricks

The problem is that those errors are hard to find, e.g. when two well-tested parts of code don't work together and you're left with no clue why.
 ABOUT WILMOTT

Wilmott.com has been "Serving the Quantitative Finance Community" since 2001. Continued...

 JOBS BOARD

Looking for a quant job, risk, algo trading,...? Browse jobs here...

GZIP: On