How to use C ++ optimization flags in SWIG?

I am creating a python module that is implemented in C ++. I use SWIG to create an interface. There are various ways to create an extension, I use the "preferred approach" which is through python distutils and which is described here . My module name is "ParseEvents", and to compile it, I run the following two commands:

swig -c++ -python ParseEvents.i
python setup.py build_ext --inplace

The first command creates the file ParseEvents_wrap.cxx

The second command uses the following setup.py file:

from distutils.core import setup, Extension

ParseEvents_module = Extension('_ParseEvents',
                               sources=['ParseEvents_wrap.cxx',],
                               extra_compile_args=["-Wno-deprecated","-O3"],
                               )
setup (name = 'ParseEvents',
              ext_modules = [ParseEvents_module,],
              py_modules = ["ParseEvents"]
              )

: , ++ -O3-? , "extra_compile_args" setup.py, , , . (python setup.py build_ext --inplace), :

running build_ext
building '_ParseEvents' extension
creating build
creating build/temp.linux-x86_64-2.6
gcc -pthread -fno-strict-aliasing -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fPIC -I/usr/include/python2.4 -c ParseEvents_wrap.cxx -o build/temp.linux-x86_64-2.4/ParseEvents_wrap.o -Wno-deprecated -O3
c++ -pthread -shared build/temp.linux-x86_64-2.4/ParseEvents_wrap.o -o _ParseEvents.so

, -O2 -O3 - --- -O2.

+3
2

GCC :

http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Optimize-Options.html

If you use multiple -O options, with or without level numbers, the last such option is the one that is effective.

, -O3, . .

+3

Distutils , Python. , - . , , . , , , , .

, , -O2 .

0

All Articles