Import constants from .h file into python

前端 未结 4 991
青春惊慌失措
青春惊慌失措 2021-02-07 09:56

I\'ve been looking for a simple answer to this question, but it seems that I can\'t find one. I would prefer to stay away from any external libraries that aren\'t already includ

4条回答
  •  礼貌的吻别
    2021-02-07 10:25

    I'd up-vote emilio, but I'm lacking rep!

    Although you have requested to avoid other non-standard libraries, you may wish to take a look at Cython (Cython: C-Extensions for Python www.cython.org/), which offers the flexibility of Python coding and the raw speed of execution of C/C++-compiled code.

    This way you can use regular Python for everything, but handle the expensive elements of code using its built-in C-types. You can then convert your Python code into .c files too (or just wrap external C-libraries themselves. ), which can then be compiled into a binary. I've achieved up to 10x speed-ups doing so for numerical routines. I also believe NumPy uses it.

提交回复
热议问题