Introduction: One of the best methods of speeding up your python codes is turning it into a cython code. For turning a python script to cython, you need to save it with a pyx extension and then compile it using a setup file . For example, say you have a file named helloworld.pyx. To compile this, your code inside setup file will look like: from setuptools import setup from Cython.Build import cythonize setup ( ext_modules = cythonize ( "helloworld.pyx" ) ) Now, after doing this, you have to run this setup file using the following command which creates a .c and a .so file. $ python setup.py build_ext --inplace The Problem: So even after compiling, you may end up getting: importerror:... undefined symbol: _py_ZeroStruct when you try and import the compiled cython module. Why does it happen? and the solution: the source of this problem, according to the stackoverflow is the mismatch between the python version of the compiled cython code and the python f...
I write about machine learning models, python programming, web scraping, statistical tests and other coding or data science related things I find interesting. Read, learn and grow with me!