extension-modules

C++ Python module import error: “undefined symbol: Py_InitModule3” ( Py_InitModule () )

陌路散爱 提交于 2020-01-13 08:16:35
问题 I am just starting an attempt to write my first Python extension module in C and are using instructions provided at https://www.tutorialspoint.com/python/python_further_extensions.htm I am on Linux Mint 18.1, using Python 3.6.1 in its virtualenv version. As first step I have compiled a very minimalistic version of the Python module I plan to write. Here my C-code: include <Python.h> static PyObject* uniqueCombinations(PyObject* self) { return Py_BuildValue("s", "uniqueCombinations() return

Cross module dependencies in Boost Python

情到浓时终转凉″ 提交于 2019-12-19 02:39:31
问题 Suppose I have two boost python modules that are defined as follows. Module A: class SomeClass { public: SomeClass() {} ~SomeClass() {} }; BOOST_PYTHON_MODULE(A) { class_<SomeClass>("SomeClass"); } And module B: class AnotherClass { public: AnotherClass() {} ~AnotherClass() {} void func(SomeClass& sp) {} }; BOOST_PYTHON_MODULE(B) { class_<AnotherClass>("AnotherClass") .def("func", &AnotherClass::func) ; } Module B has a dependency on module A (i.e. it uses SomeClass from module A). Now, I

In Python how can one tell if a module comes from a C extension?

你。 提交于 2019-12-12 07:14:08
问题 What is the correct or most robust way to tell from Python if an imported module comes from a C extension as opposed to a pure Python module? This is useful, for example, if a Python package has a module with both a pure Python implementation and a C implementation, and you want to be able to tell at runtime which one is being used. One idea is to examine the file extension of module.__file__ , but I'm not sure all the file extensions one should check for and if this approach is necessarily

_functools module

送分小仙女□ 提交于 2019-12-07 08:22:06
问题 How does this import work, what file does it use? import _functools In python 2.5: import _functools print _functools.__file__ Gives: Traceback (most recent call last): File "D:\zjm_code\mysite\zjmbooks\a.py", line 5, in <module> print _functools.__file__ AttributeError: 'module' object has no attribute '__file__' How can I get the meaning of partial (from _functools import partial) if I can't read C code? 回答1: C-coded modules can be built-in (lacking __file__ ) or live in a .so or .pyd

_functools module

☆樱花仙子☆ 提交于 2019-12-05 17:33:08
How does this import work, what file does it use? import _functools In python 2.5: import _functools print _functools.__file__ Gives: Traceback (most recent call last): File "D:\zjm_code\mysite\zjmbooks\a.py", line 5, in <module> print _functools.__file__ AttributeError: 'module' object has no attribute '__file__' How can I get the meaning of partial (from _functools import partial) if I can't read C code? C-coded modules can be built-in (lacking __file__ ) or live in a .so or .pyd dynamic library (which their __file__ will indicate) -- that's an implementation detail that you should not care

How to call a builtin function (or method) from C code of a Python extension module?

家住魔仙堡 提交于 2019-12-02 08:43:17
问题 What I currently want to accomplish is to tweak Pythons itertools module function combinations to sort the passed iterable before creating combinations out of it with the goal of having the returned combinations sorted. I am working on a Python extension module for the first time and my only experience up to now was to write and compile a "Hello World" like Python extension module, but I hope that my overall programming experience in a couple of programming languages is a solid enough

add extension module to groovy class

吃可爱长大的小学妹 提交于 2019-12-01 10:54:39
I am trying to create simple extension module . I created Main.groovy file class Item { String item } new Item().sayHello() // this method supposed to be extension I compiled it (not ran). I created ItemExtension.groovy class class ItemExtension { def sayHello(Item self) { println "hello world" } } This is my org.codehaus.groovy.runtime.ExtensionModule descriptor moduleName=Item extension module moduleVersion=1.0 extensionClasses=ItemExtension I compiled ItemExtension.groovy using groovyc (I precompiled Main.groovy in order to get Item class) groovyc ItemExtension.groovy Compiled ItemExtension

add extension module to groovy class

爱⌒轻易说出口 提交于 2019-12-01 08:16:14
问题 I am trying to create simple extension module . I created Main.groovy file class Item { String item } new Item().sayHello() // this method supposed to be extension I compiled it (not ran). I created ItemExtension.groovy class class ItemExtension { def sayHello(Item self) { println "hello world" } } This is my org.codehaus.groovy.runtime.ExtensionModule descriptor moduleName=Item extension module moduleVersion=1.0 extensionClasses=ItemExtension I compiled ItemExtension.groovy using groovyc (I

DLL Load Failed: %1 is not a valid win32 application

99封情书 提交于 2019-12-01 06:48:51
So I have a situation where I need to make binary patches and then be able to apply them from within python. I found bsdiff which looks like a great algorithm and has a python extension module , but that extension module doesn't have a windows installer past Python 2.5 Alright, so having never even written C seriously, let alone attempted a python extension module, I set out to compile it myself. After a few hours of bashing my head against a DLL load error with MinGW32, I managed to get it compiled and built using the setup.py provided in the source of the project. However, upon importing the

DLL Load Failed: %1 is not a valid win32 application

久未见 提交于 2019-12-01 04:46:55
问题 So I have a situation where I need to make binary patches and then be able to apply them from within python. I found bsdiff which looks like a great algorithm and has a python extension module, but that extension module doesn't have a windows installer past Python 2.5 Alright, so having never even written C seriously, let alone attempted a python extension module, I set out to compile it myself. After a few hours of bashing my head against a DLL load error with MinGW32, I managed to get it