On Sat, Sep 25, 2010 at 12:09 AM, Kay Hayen <[email protected]> wrote:
>
> Hello,
>
> when I compile pure Python code with Cython 0.12 and/or Cython 0.13,
> which are the options recommended for optimal performance. I am doing
> some comparative benchmarking to CPython based on Valgrind and I wonder
> if I am doing it correctly.
>
> Currently I only use:
>
> cython --embed
>
> and from cython --help (0.12)
>
> there wasn't much else I could try. so is that all?

In general, there aren't dozens of knobs to twiddle like there are
with most compilers.

There are a couple of directives at
http://wiki.cython.org/enhancements/compilerdirectives that might make
a difference. For example, setting boundscheck and wraparound to False
will make things faster (removing the checks for negative and
out-of-bounds access of course), and infer_types=True (again, this
creates semantic changes, as integer literals will be inferred to be C
ints and thus might overflow). And I'd imagine that 0.13 will be an
improvement over 0.12, at least for some things.

> Any difference expected between C and C++ code generation?

Not that I am aware of. Cython doesn't use any specific C++ features
(unless you're explicitly linking against C++ libraries) so it should
all be the same (but it'd be interesting to test).

> And then what to use for gcc (the C/C++ compiler of choice or is any
> other working for you better on Linux), simply -O3 and be done with it?

That's all I do, but there's a lot of options to try, so it'd be
interesting to see if any make a noticeable impact. (Same with
comparing various compilers.)

> Or is there any experience indicating that some special options will
> give measurable improvements?
>
> Obviously I would like to first use the correct options and only then
> publish results. So please let me know. :-)

It should be noted that most of the effort has gone into making
*annotated* code fast, as most users care more about a 100x speedup
with a little bit of work than a 2x speedup for free.

- Robert
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to