cython

Cythonize python dictionary object

孤街浪徒 提交于 2021-01-25 07:17:35
问题 I am using cython to improve the performance of the python functions. Basically i can improve performance only in dictionary operations. So i was trying to search for any dictionary written in c, I found that cython itself contains a .pxd file which is basically wrapper for .h file at "Cython/includes/cpython". My question is if i directly use cimport dict ,how to include the above mentioned path while compiling? If i use this dict.pxd will i get any improvement in performance ? I attached

pyclipper installation error: “tp_print is not a member of _typeobject”

假如想象 提交于 2021-01-16 03:51:58
问题 I'm trying to install pyclipper to use with nototools. https://github.com/googlefonts/nototools But I can't get pyclipper installed. I think there is something with Visual Studio buildtools. Collecting pyclipper==1.1.0.post1 Using cached pyclipper-1.1.0.post1.zip (135 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing wheel metadata ... done Building wheels for collected packages: pyclipper Building wheel for pyclipper (PEP 517) ... error ERROR:

undefined symbol in Cython module when using mlpack

亡梦爱人 提交于 2021-01-13 09:37:17
问题 I met the problem "undefined symbol" when using mlpack in Cython. Here is my test case: cdef extern from "<mlpack/core.hpp>" namespace "arma": ctypedef unsigned uword cdef cppclass vec: vec() vec(uword) cdef cppclass mat: mat() mat(uword, uword) void matprint "print" () double& operator() (const uword, const uword) cdef extern from "<mlpack/methods/pca/pca.hpp>" namespace "mlpack::pca": cdef cppclass ExactSVDPolicy: ExactSVDPolicy() cdef cppclass PCA[ExactSVDPolicy]: PCA() void Apply(const

Cython “Cannot assign default value to fields in cdef classes, structs or unions”

允我心安 提交于 2021-01-05 12:59:36
问题 I am making my first attempt at porting Python code to Cython. I only have very limited experience with C. I am trying to make a relatively simple class that stores multidimensional arrays. For the purpose of this question, let's leave it to a single one-dimensional array of length 1 for the attribute time. Currently, I am recieving the error: cdef np.ndarray[np.int64_t, ndim=1] time = np.empty([1], dtype=np.int64) ^ ------------------------------------------------------------ data.pyx:22:40:

buildozer + Cython + C++ library: dlopen failed: cannot locate symbol symbol-name referenced by module.so

吃可爱长大的小学妹 提交于 2021-01-05 12:53:34
问题 phase_engine.so tries to use _ZTINSt6__ndk18ios_base7failureE and can't find it: 11-08 19:59:00.629 25777 25823 I python : Traceback (most recent call last): 11-08 19:59:00.629 25777 25823 I python : File "/home/sonoflilit/phase/phase/.buildozer/android/app/main.py", line 14, in <module> 11-08 19:59:00.629 25777 25823 I python : ImportError: dlopen failed: cannot locate symbol "_ZTINSt6__ndk18ios_base7failureE" referenced by "/data/data/il.co.loris.phase/files/app/_python_bundle/site-packages

buildozer + Cython + C++ library: dlopen failed: cannot locate symbol symbol-name referenced by module.so

自古美人都是妖i 提交于 2021-01-05 12:47:47
问题 phase_engine.so tries to use _ZTINSt6__ndk18ios_base7failureE and can't find it: 11-08 19:59:00.629 25777 25823 I python : Traceback (most recent call last): 11-08 19:59:00.629 25777 25823 I python : File "/home/sonoflilit/phase/phase/.buildozer/android/app/main.py", line 14, in <module> 11-08 19:59:00.629 25777 25823 I python : ImportError: dlopen failed: cannot locate symbol "_ZTINSt6__ndk18ios_base7failureE" referenced by "/data/data/il.co.loris.phase/files/app/_python_bundle/site-packages

buildozer + Cython + C++ library: dlopen failed: cannot locate symbol symbol-name referenced by module.so

元气小坏坏 提交于 2021-01-05 12:47:39
问题 phase_engine.so tries to use _ZTINSt6__ndk18ios_base7failureE and can't find it: 11-08 19:59:00.629 25777 25823 I python : Traceback (most recent call last): 11-08 19:59:00.629 25777 25823 I python : File "/home/sonoflilit/phase/phase/.buildozer/android/app/main.py", line 14, in <module> 11-08 19:59:00.629 25777 25823 I python : ImportError: dlopen failed: cannot locate symbol "_ZTINSt6__ndk18ios_base7failureE" referenced by "/data/data/il.co.loris.phase/files/app/_python_bundle/site-packages

Renamed .c files to .cpp, importing Cython library fails

怎甘沉沦 提交于 2021-01-04 09:04:21
问题 I had a working Cython program which wrapped some C libraries and custom C code. Recently, I had to switch my project to C++, so I renamed all my C code to *.cpp . Cython compiled fine and produced the .so file. However, when I try to import my library in Python, I get the following error. File "example.py", line 1, in <module> from tag36h11_detector import detect ImportError: dlopen(/Users/ajay/Documents/Code/calibration/apriltag_detector/examples/tag36h11_detector.cpython-36m-darwin.so, 2):

Prevent double compilation of c files in cython

点点圈 提交于 2020-12-12 11:14:29
问题 I am writing a wrapper over c libriary and this lib has file with almost all functions, let say, all_funcs.c . This file in turn requires compilation of lots of another c files I have created all_funcs.pyx , where I wraped all functions, but I also want to create a submodule, that has access to functions from all_funcs.c . What works for now is adding all c-files to both Extensions in setup.py, however each c-file compiles twice: first for all_funcs.pyx and second for submodule extension. Are

如何保护你的 Python 代码 (一)—— 现有加密方案

南笙酒味 提交于 2020-12-10 06:00:48
👆 “ Python猫 ” ,一个值得加星标的 公众号 花下猫语: Python 是一种入门容易的语言,初学者就可以轻松地完成各种任务,但是,Python 的用处与边界也很广,有太多的话题值得我们去研究探索。 今天,我继续给大家分享一篇优质的进阶文章,让我们一起学习进步吧! 作者: Prodesire(经作者授权转载) 出处: https://zhuanlan.zhihu.com/p/54296517 剧照 | 《神雕侠侣》 0 前言 去年11月在PyCon China 2018 杭州站分享了 Python 源码加密,讲述了如何通过修改 Python 解释器达到加解密 Python 代码的目的。然而因为笔者拖延症发作,一直没有及时整理成文字版,现在终于战胜了它,才有了本文。 本系列将首先介绍下现有源码加密方案的思路、方法、优点与不足,进而介绍如何通过定制 Python 解释器来达到更好地加解密源码的目的。 由于 Python 的动态特性和开源特点,导致 Python 代码很难做到很好的加密。社区中的一些声音认为这样的限制是事实,应该通过法律手段而不是加密源码达到商业保护的目的;而还有一些声音则是不论如何都希望能有一种手段来加密。于是乎,人们想出了各种或加密、或混淆的方案,借此来达到保护源码的目的。 常见的源码保护手段有如下几种: 发行 .pyc 文件 代码混淆 使用 py2exe