
[英]Is there a way to iterate over struct attributes?
抱歉,如果之前有人问过这个问题。 看起来确实很简单。 我想知道是否有一种方法可以迭代结构属性。 例如 ...
[英]Is there a way to iterate over struct attributes?
抱歉,如果之前有人问过这个问题。 看起来确实很简单。 我想知道是否有一种方法可以迭代结构属性。 例如 ...
[英]I don't know how to wrap the .c file and.pyx file code
我是 Cython 的初学者,我正在从 O'Reilly 的 Cython 书中学习它,我在代码中有一个问题,我不知道如何包装 .c 文件(C 文件)和 .pyx 文件的代码(Cython 文件)用于在 python 中使用 (wrap_fib.py 文件)代码在这里:- (wrap_fib ...
[英]derive class from from sklearn.cluster.KMeans with cython
我喜欢创建 scikit-learns 的sklearn.cluster.KMeans的孩子 class 并且出于性能原因想在 cython 中执行此操作。 这可能吗? 有一个旧问题https://github.com/scikit-learn/scikit-learn/issues/2057这似 ...
[英]using special function such as __add__ in cython cdef classes
我想创建一个 cython object,它可以进行方便的操作,例如加法乘法和比较。 但是当我编译这些类时,它们似乎都有很多 python 开销。 一个简单的例子: 但是我最终从带注释的编译器中得到了相当大的读数似乎 __add__ function 正在将对象从 python 浮点数转换为 cy ...
[英]cythonize not found on Ubuntu 22.04 after "pip3 install cython"
Command: cythonize rednose/helpers/ekf_sym_pyx.pyx Error: sh: 1: cythonize: not found 我最近安装了 Ubuntu 22.04。 我试图安装https://github.com/commaai/rednose 。 ...
[英]Why does adding an __init__.py change Cython build_ext --inplace behavior?
这是我遇到的问题的玩具版本。 我正在尝试使用 setuptools 来编译一些 Cython 代码,作为更大项目的一部分。 我的 topdir 是test 。 它包含: hello_world.pyx 和 setup.py 如果我使用python3 setup.py build_ext ...
[英]How to declare a c++ tuple in cython
我有一个 C++ 方法声明如下:std::tuple<std::vector<int>, std::size_t, std::size_t> get_state(); // Should I use a struct and expose the struct instead ...
[英]multi processing using ctyhon
基本上,我有一个使用 pyqt5 构建的 GUI 应用程序,我正在使用 cython 进行其他操作。 这里的目标是,当我从 pyqt5 应用程序中单击一个按钮时,应该创建一个调用 cython function 的新进程,或者我不希望我的 pyqt5 GUI 应用程序因为 foo() functio ...
[英]type hinting, class inheritance and metaclass with a cython lib
我正在使用一个名为pygrib的cython库,它没有任何关联的类型提示。 我想通过包装来扩展它的功能,例如某些具有相对类型提示的类中的pygrib.open方法。 pygrib.open返回一个带有pygrib.messages的Iterator 班级from abc import ABCMet ...
[英]Storing unsafe C derivative of temporary Python reference Cython
虽然我已经问了几个类似的问题,但我无法解决如何解决问题。 基本上我有这个 function: 模块一.pyx: 模块二.pyx: 问题发生在str = one.isInData("Hello what is up World", 23)行,我假设一旦isInData->ret被分配给str 。 ...
[英]Segmentation fault in Cython
我是 Cython 的新手。 我写了一个返回 2D Numpy 或 memoryview 数组的 pyx 文件。 这是 pyx 代码:import numpy as np import cython cimport numpy as np from libc.math cimport int @c ...
[英]Convert bitarray to image
我有一个大的位数组作为开始 100 000 000 位,即 10000x10000。 将其转换为缩小版本的最可行和最经济的方法可能是 1000x1000,通过最好地保留 dot|1 分布。 不知道B&W还是gray img会更好。 对于数组,我使用 bitarray 模块,对于图像 bock ...
[英]Writing a custom main() function with Embedded Cython modules in C
我对 Cython 世界相当陌生,但我很了解 C 和 Python。 我正在尝试使用 Cython 将 Python 代码编译成 C,但我需要在 C 中编写自己的 main() function。 我只在网上找到了一个代码示例,该代码是从 C 程序编译而来的,该程序调用了用 Python/Cyth ...
[英]Cython: Generic function interfacing functions based on call signature
基本上,想要编写两个函数,然后使用第三个泛型 function,它纯粹根据给定的输入 arguments 选择两个原始函数中的哪一个来调用给定的 arguments。 例如 显然我可以用 if 语句来做到这一点,但对我来说这似乎效率不高。 任何和所有帮助表示赞赏,干杯。 ...
[英]Calling Cython(C) functions with python functions as argument
我想将本地定义的 python 函数与 gsl 库集成。 为此,我用 Cython 实现了以下代码(Gauss-Legendre 正交示例): px文件: 和 pyx 文件: 此代码适用于在我的 Cython 代码中声明的任何 C function。 当然,当我将 python function ...
[英]decompile cython extension back to python
我使用 cythonize 编译我的 python 模块。 这样可以提高代码速度,并且开发人员也无法阅读代码。 但是我怀疑一些 python 开发人员是否可以破解那个 cython 模块来破解代码。 问题是,有人可以将它们反编译回 python 或其他可读格式来破解代码吗? ...
[英]Fastest approach for iteration over iterable with elements of 16 bytes in cython
我在 python 中有一个bytes列表,我想遍历该列表并找到特定byte序列q的第一次出现。 我想使用 numpy 数组,但 numpy 数组或本机 python 数组中的元素类型似乎被限制为 64 位。 我不需要使用 python list作为 function 的输入。是否有另一个可以使 c ...
[英]Is it possible to compile Cython modules without a Visual Studio license on Windows for commercial purposes? What are the alternatives?
这是关于在不使用付费 Microsoft Visual Studio 许可证的情况下在 Windows 机器上编译 Cython 模块(或类似的内置 Python 模块,例如 PYD 文件): 我尝试了很多不同的解决方案,从安装 minGW、安装 windows 到 SDK,但没有任何效果。 在W ...
[英]Is there a limit to how large an array can be inside of a function in cython?
这段代码编译并运行得很好: 但是这段代码: 使 python kernel 崩溃(我正在使用 jupyter magic 运行它)。 函数内部的 arrays 有多大限制? 如果有,有没有办法取消该限制? ...