Questions tagged [cythonize]

Use this tag for questions about the compilation of python extension modules based on cython using "cythonize". Use the more generic [cython] tag if the question isn't about the actual compilation process.

The cythonize function can be imported from Cython.Build and is used to compile extensions for python. It is responsible for compiling the .pyx (cython files) to .c files.

The cython "Compilation" documentation contains several examples how to include cythonize in the build process for python modules.

342 questions
4
votes
1 answer

Create Executable from a Python module with Pyinstaller or Cython

I want to convert to an executable this python 2.7 project that has a module structure: (.venv) ip-192-168-22-127:indictrans loretoparisi$ tree -L 1 . ├── __init__.py ├── __init__.pyc ├── __init__.spec ├── _decode ├── _utils ├── base.py ├──…
loretoparisi
  • 15,724
  • 11
  • 102
  • 146
4
votes
1 answer

Cython: Invalid use of fused types, type cannot be specialized

I have the following MCVE: import numpy as np cimport numpy as np cimport cython from cython cimport floating def func1(floating[:] X_data, floating alpha): if floating is double: dtype = np.float64 else: dtype =…
P. Camilleri
  • 12,664
  • 7
  • 41
  • 76
4
votes
0 answers

Why aren't debugging symbols loaded for my Cython application?

I am utilizing Cython to invoke a C++ API from python, and I'd like to debug the application. My setup.py file is structured as follows: from distutils.core import setup from distutils.extension import Extension from distutils.util import…
Kirby
  • 3,649
  • 3
  • 26
  • 28
4
votes
1 answer

How to compile a whole Python library (including dependencies) so that it can be used in C?

How to compile a whole Python library along with it's dependencies so that it can be used in C (without invoking Python's runtime). That is, the compiled code has the Python interpreter embedded and Python does not need to be installed on the…
Greg
  • 8,175
  • 16
  • 72
  • 125
4
votes
1 answer

How to make Python module shareable?

We have a python based module which we want to distribute to our customers by creating a compiled copy understandable by linux system(i.e. .so file) We have evaluated cython which does this quite easily, but we're seeing it's creating as many .so…
Vardan Gupta
  • 3,505
  • 5
  • 31
  • 40
4
votes
1 answer

LINK : fatal error LNK1104: cannot open file 'C:\Users\hp\.pyxbld\lib.win32-2.7\gensim\models\word2vec_inner.pyd'

I run the sourcecode of TWE model. I need to compile the C extension of python. I have installed the Microsoft Visual C++ Compiler for Python 2.7 and Cython. First, I need to run the TWE/train.py: import gensim sentence_word =…
wangtingc
  • 41
  • 5
4
votes
1 answer

How to build cython pyx to pyd in anaconda(python3.6) in windows 8.1?

I have referred some websites to build pyx to pyd in Windows 8.1.I 'm using Anaconda Distribution with Spyder IDE, I have developed pyx file and unable to build in "Anaconda Command Prompt" Anaconda> python setup.py build --inplace…
4
votes
1 answer

Cython compile module in separate directory

I am a newbie to cython. I've the following directory structure. cython_program/ cython_program/helloworld.py cython_program/lib/printname.py helloworld.py: import lib.printname as name def printname(): name.myname() printname.py: def…
Mj1992
  • 3,404
  • 13
  • 63
  • 102
4
votes
1 answer

Cython cimport cannot find .pxd module

Solved, see Edit #3 Assume a package is structured as: Some_Package/ some_package/ __init__.py core/ __init__.py definition.pxd helper/ __init__.py helper.pxd …
Jiayao Zhang
  • 170
  • 1
  • 9
4
votes
1 answer

Attempting to build a cython extension to a python package, not creating shared object (.so) file

I have attempted to use the answer here to add the building of a cython extension into my package. It currently cythonizes the code to produce a .c file from the .pyx file but doesn't create a shared object .so file, as such when I try to import the…
SomeRandomPhysicist
  • 1,531
  • 4
  • 19
  • 42
4
votes
1 answer

Error when converting C code to Web Assembly

I have successfully installed Emscripten and have it running on an Ubuntu 16.04 virtual machine. I have also successfully converted a helloworld.c file to web assembly. Currently, I am attempting to convert python to web assembly with emscripten.…
Robbie
  • 1,733
  • 2
  • 13
  • 20
4
votes
0 answers

Which is faster : defaultdict in python or libcpp.map in cython?

I am trying to optimize a function which store words and its count. Python implementation is quite slow as of now. I am trying to cythonize the function. What other alternatives do we have in cython corresponding to defaultdict ?
4
votes
2 answers

save cython extension by pickle

I have a class or extension type written in cython like this: cdef class Self_Organized_Map: cdef def __cinit__(self,np.ndarray data,.....): .... I created a python module from this cython file (which its name is som.pyx) using…
Javad Sameri
  • 1,218
  • 3
  • 17
  • 30
3
votes
1 answer

Am I doing cythonization right?

I am trying to get cython to work on a project. What I do is the following: Create a file called make_cython.py import distutils.core import Cython.Build distutils.core.setup(ext_modules =…
kloop
  • 4,537
  • 13
  • 42
  • 66
3
votes
1 answer

Cython and clang on mac, "Python.h not found"

I'm running clang on mac to compile a c file created by running a very simple program through cython, but the compiler always give me a "Python.h not found" fatal error. I've tried every solution I could find, reinstalling python 3.9, using the…
James Bord
  • 31
  • 2
1 2
3
22 23