Questions tagged [pythran]

Pythran is a Python-subset-to-C++-transcompiler, geared towards speeding up scientific programs by using available processor-level parallelism.

Pythran transcompiles Python modules written in a subset of the Python language and annotated with some interface description to to system-native (C++) code. The result is a new Python module wrapping the generated C++ code, with the same interface as the original module.

The aim of this conversion is a runtime speedup due to

  • system-native instead of interpreted/JiT-compiled code
  • usage of multiple cores
  • usage of units

Pythran is geared towards scientific programs.

25 questions
6
votes
1 answer

Most efficient way to sort an array into bins specified by an index array?

The task by example: data = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9]) idx = np.array([2, 0, 1, 1, 2, 0, 1, 1, 2]) Expected result: binned = np.array([2, 6, 3, 4, 7, 8, 1, 5, 9]) Constraints: Should be fast. Should be O(n+k) where n is the length of…
Paul Panzer
  • 51,835
  • 3
  • 54
  • 99
5
votes
2 answers

Is it possible to / How to get the c++ code generated from running pythran on python

Pythran is a Python-to-C++ compiler for a subset of Python that includes partial numpy support. It acts a little like Numba and Cython—you annotate a function’s arguments, and then it takes over with further type annotation and code…
ntg
  • 12,950
  • 7
  • 74
  • 95
3
votes
1 answer

pythran - File format not recognized and Unknown MS Compiler version 1800

I am new to pythran and right now encountering the problem of File format not recognized as follow: D:\DevWorkSpace\cython>pythran dprod.py WARNING Pythran support disabled for module: omp Looking for python27.dll objdump.exe: D:\Program…
J. Wu
  • 33
  • 4
2
votes
1 answer

How to view-cast / reinterpret-cast in pythran / numpy?

I'm trying to do numpy view-casting (which I believe in C/C++ land would be called reinterpret-casting) in pythran: The following silly made-up example takes an array of unsigned 8-byte integers, reinterprets them as twice as many unsigned 4-byte…
Albert.Lang
  • 523
  • 3
  • 8
2
votes
1 answer

Setting up Pythran for compiling on Windows with clang-cl.exe and OpenMP working: need a way to pass compiler arguments

I'm using Pythran to compile Python code into C/C++ with OpenMP support on Windows. Now the documentation isn't great for Windows - it states: "Windows support is on going and only targets Python 3.5+ with either Visual Studio 2017 or, better,…
Matt
  • 2,602
  • 13
  • 36
2
votes
1 answer

Transonic run python code instead of pythran

After the first good results with pythran, I tried transonic to benefit form the jit and the class support. Unfortunately it does not run as expected. If I use the @jit decorator the decorated functions are compiled and cached, but during the first…
rqwa
  • 47
  • 5
2
votes
1 answer

How to speedup multiple broadcasts in Julia

This Julia function seems to be quite inefficient (an order of magnitude slower than the equivalent Pythran / C++ code, even after the Julia warmup)... function my_multi_broadcast(a) 10 * (2*a.^2 + 4*a.^3) + 2 ./ a end arr = ones(1000,…
paugier
  • 1,838
  • 2
  • 20
  • 39
2
votes
1 answer

Wrong result using a PyCapsule created from a method in Cython

We would need to create a PyCapsule from a method of a class in Cython. We managed to write a code which compiles and even runs without error but the results are wrong. A simple example is here:…
paugier
  • 1,838
  • 2
  • 20
  • 39
1
vote
0 answers

Python Embedding to C++ using static library

I want to use python code in C++ in an environment where we only have support for C++. It turns out that using python embedding, we can call python functions using C/C++. If I want to interpret python in C++, using python.h and libpython: Do I need…
taserghar
  • 340
  • 3
  • 15
1
vote
0 answers

Pythran with XSIMD - help vectorizing loop (Python)

NOTE: I'm trying to rewrite this Python function which is decorated to compile with Pythran into a Python module. It currently uses OpenMP fine but not SIMD. pythran -DUSE_XSIMD my-script.py So the bounty is for rewriting a bit of Python code to…
Matt
  • 2,602
  • 13
  • 36
1
vote
1 answer

write text files in pythran fails

I'm working with pythran, a Python to c++ compiler http://pythran.readthedocs.io/ In its manual page, pythran says it supports the method write from TextIOWrapper However, trying to compile this simple file file: mylib.py #pythran export…
Girardi
  • 2,734
  • 3
  • 35
  • 50
1
vote
2 answers

Very large in-place numpy array operations : numba, pythran or other?

tI need to perform operations on very large arrays (several millions entries), with the cumulated size of these arrays close to the available memory. I'm understanding that when doing naive operation using numpy like a=a*3+b-c**2, several temporary…
rdrien
  • 65
  • 4
1
vote
1 answer

How to call fft with pythran

I'm using pythran to convert my python+numpy code into C++, so far everything works really well with very efficient resulting code. However, my code requires the use of numpy.ffr.rfft and irfft (Fast Fourier Transform), which pythran apparently does…
jeanl
  • 11
  • 4
1
vote
1 answer

Use datetime in pythran

I'm working with pythran, a Python to c++ compiler http://pythran.readthedocs.io/ Can we use datetime or any other way to use in pythran function a date or a time info ?: from datetime import datetime print datetime.now() I get: $ pythran…
user3313834
  • 7,327
  • 12
  • 56
  • 99
0
votes
0 answers

Uncatchable error: `Assertion failed: b != 0 && "divide by zero"` in python with scipy.signal.lombscargle

I recently decided to dip my foot into some datascience and to experiment with pandas and scipy. So I am trying to run scipy's Lomb-Scargle periodogram on some data. Since I have around 7000 datafiles and am trying to find common frequencies among…
leonhma
  • 110
  • 9
1
2