How can I set Cython compiler flags when using pyximport?

Thomas Johnson

This question (How does one overwrite the default compile flags for Cython when building with distutils?) describes how to set default Cython flags when using distutils.

But how do I set default compile flags if I'm just using pyximport?

import pyximport
pyximport.install()  # Pass compile flags here somehow?
Blake Walsh

You should use a .pyxbld file, see for example this question. For a file named foo.pyx, you would make a foo.pyxbld file. The following would give extra optimization args:

def make_ext(modname, pyxfilename):
    from distutils.extension import Extension
    return Extension(name=modname,
                     sources=[pyxfilename],
                     extra_compile_args=['-O3', '-march=native'])

I think it might be possible to pass in extra setup options to pyximport.install if you jump through enough hoops (messing around with distribute) to get the setup_args in the form it likes, however in the pyximport module documentation it recommends using a .pyxbld file, and in the test code for pyximport only that method is tested, so if there is another way it should be considered unstable/untested and .pyxbld should be considered the proper way of doing this.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

how to reload a cython module interactively using pyximport

From Dev

How to set compiler-specific flags with autotools

From Dev

How to set flags of g++ using cmake such that gprof can demangle?

From Dev

Cython: how can I set the attribute of a cdef class?

From Dev

How can I set a compiler warning (GNU GCC) when overwriting a weak function

From Dev

How can I reliably modify build configs and add compiler flags in C/C++ RPM files?

From Dev

How can I render country flags as a ribbon, using CSS only?

From Dev

How can I change chrome://flags using chrome API?

From Dev

How can I set the sizes of nodes when using graphviz on python?

From Dev

How can I set the MessageGroupId when using MassTransit SQS?

From Dev

How can I force compiler to use default constructor when adding element to vector using emplace_back?

From Dev

Weird flags when building LLVM project with Make using the Clang Compiler

From Dev

How can I install cython

From Dev

CMAKE set rc compiler flags?

From Dev

Where does cython pyximport compile?

From Dev

How can one configure mex to pass compiler flags to nvcc

From Dev

how can i add popup to flags in highchart?

From Dev

When using custom cursors, how can you set the I-bar cursor when hovering over text?

From Dev

Why does C# compiler create private DisplayClass when using LINQ method Any() and how can I avoid it?

From Dev

Can I set flags as 0 in PendingIntent.getService

From Dev

How can I read the lines between the "start" and "end" flags from a file by using python

From Dev

How can I handle flags without parameters in bash without using getopts?

From Dev

How can I set this value using ajax

From Dev

How can I set gravity using this code?

From Dev

How can I use mlpack in Cython?

From Dev

How can I set the initial value of Select2 when using AJAX?

From Dev

How can I set the Cache-Control when using Write-S3Object?

From Dev

How can I set the list index when using Super Simple View Engine

From Dev

How can I set an errorProvider against ALL invalid form controls when using this.validateChildren()?

Related Related

  1. 1

    how to reload a cython module interactively using pyximport

  2. 2

    How to set compiler-specific flags with autotools

  3. 3

    How to set flags of g++ using cmake such that gprof can demangle?

  4. 4

    Cython: how can I set the attribute of a cdef class?

  5. 5

    How can I set a compiler warning (GNU GCC) when overwriting a weak function

  6. 6

    How can I reliably modify build configs and add compiler flags in C/C++ RPM files?

  7. 7

    How can I render country flags as a ribbon, using CSS only?

  8. 8

    How can I change chrome://flags using chrome API?

  9. 9

    How can I set the sizes of nodes when using graphviz on python?

  10. 10

    How can I set the MessageGroupId when using MassTransit SQS?

  11. 11

    How can I force compiler to use default constructor when adding element to vector using emplace_back?

  12. 12

    Weird flags when building LLVM project with Make using the Clang Compiler

  13. 13

    How can I install cython

  14. 14

    CMAKE set rc compiler flags?

  15. 15

    Where does cython pyximport compile?

  16. 16

    How can one configure mex to pass compiler flags to nvcc

  17. 17

    how can i add popup to flags in highchart?

  18. 18

    When using custom cursors, how can you set the I-bar cursor when hovering over text?

  19. 19

    Why does C# compiler create private DisplayClass when using LINQ method Any() and how can I avoid it?

  20. 20

    Can I set flags as 0 in PendingIntent.getService

  21. 21

    How can I read the lines between the "start" and "end" flags from a file by using python

  22. 22

    How can I handle flags without parameters in bash without using getopts?

  23. 23

    How can I set this value using ajax

  24. 24

    How can I set gravity using this code?

  25. 25

    How can I use mlpack in Cython?

  26. 26

    How can I set the initial value of Select2 when using AJAX?

  27. 27

    How can I set the Cache-Control when using Write-S3Object?

  28. 28

    How can I set the list index when using Super Simple View Engine

  29. 29

    How can I set an errorProvider against ALL invalid form controls when using this.validateChildren()?

HotTag

Archive