Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #81887

Re: Python, C++ interaction

From Sturla Molden <sturla.molden@gmail.com>
Subject Re: Python, C++ interaction
Date 2014-12-04 09:50 +0000
References <547EC9E2.8070502@perfect-kreim.de> <CAGGBd_oEtFqDG6OPVE+AZYZvCRRPMWjKk5RiFzcaLZqia+K+Zg@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.16550.1417686652.18130.python-list@python.org> (permalink)

Show all headers | View raw


Dan Stromberg <drsalists@gmail.com> wrote:

> 1) writing in Cython+CPython (as opposed to wrapping C++ with Cython)

That is an option, but it locks the code to Cython and CPython forever. C
and C++ are at least semi-portable.

> 2) using numba+CPython (It's a pretty fast decorator - I've heard it's
> faster than Cython)

Numba is usually not "faster than Cython" (Cython can be as fast as C), but
it can be pretty fast. Sometimes it is comparable to -O2 in C for the
subset of Python it supports, but usually a bit slower. But if you can use
it, it is easier to use than Cython. There are no extra compilation steps,
etc. Just add a couple of decorators to the Python code and it takes off
like a rocket. For anyone who are familiar with PyPy and Psyco, Numba is
far better than those. It is a Python JIT compiler that often can perform
better than the Java VM. Numba will also JIT-compile Python code that uses
ctypes or cffi to call external libraries down to almost zero overhead.

You forgot to mention using Fortran and f2py. Many scientists and engineers
prefer Fortran to C and C++ because it is easier to use. And Fortran 90 and
later standards are not anything like the loathed Fortran 66 and 77
languages. Fortran is a high-level language particularly suited for
numerical computing, C is a semi-portable high-level assembler. 

Sturla

Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: Python, C++ interaction Sturla Molden <sturla.molden@gmail.com> - 2014-12-04 09:50 +0000
  Re: Python, C++ interaction wesleiramos2@gmail.com - 2014-12-05 14:17 -0800
    Re: Python, C++ interaction Sturla Molden <sturla.molden@gmail.com> - 2014-12-07 16:05 +0100
    Re: Python, C++ interaction Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-12-07 17:26 +0000
    Re: Python, C++ interaction Gayathri J <usethisid2014@gmail.com> - 2014-12-08 10:49 +0530

csiph-web