User Activity

  • Posted a comment on ticket #42 on PyCXX Python-C++ Connection

    The following example will try to demonstrate a real world use case. I have a class MyComputations which delegates heavy computation to C++. The class saves the functions it has to call, and we execute those functions (defined in the extension module) by calling its method do_computations. I have used the simple extension module which comes as a part of pycxx source distribution to make things simple. import simple # extension module defined using pycxx class MyComputations(object): def __init__(self,...

  • Posted a comment on ticket #42 on PyCXX Python-C++ Connection

    Tests in pickle_tests.py only test that a class defined in an extension is pickleable. However, the issue here is that any method defined as a part of simplemodule is unpickleable. Following tests should pass for this bug to be resolved: assert pickle.loads(pickle.dumps(simple.func)) is simple.func # test keyword method is pickleable assert pickle.loads(pickle.dumps(simple.old_style_class)) is simple.old_style_class # test varargs method is pickleable # Also add test for noargs method

  • Modified a comment on ticket #42 on PyCXX Python-C++ Connection

    I will try to illustrate my use case below. C++: Say we have an extension called simple. // We define a class named ClassInExtension and a function named func in simple extension module. PyObject* func() { // Do some heavy computations. // Create and return an instance of ClassInExtension. } Suppose func can't be added as reduce method of the ClassInExtension. Python: from simple import func import pickle class Foo(object): def __int__(self, func, x): self.x = func(x) def __reduce__(self): return...

  • Posted a comment on ticket #42 on PyCXX Python-C++ Connection

    I will try to illustrate my use case below. C++: Say we have an extension called simple. // We define a class named ClassInExtension and a function named func in simple extension module. PyObject* func() { // Do some heavy computations. // Create and return an instance of ClassInExtension. } Suppose func can't be added as reduce method of the ClassInExtension. Python: from simple import func import pickle class Foo(object): def __int__(self, func, x): self.x = func(x) def __reduce__(self): return...

  • Posted a comment on ticket #42 on PyCXX Python-C++ Connection

    The problem is that I should be able to use a function as a part of dumping an instance. My use case is to call the function from Python to create an object after doing computations in C++. Thus I need the function to be pickleable. To answer whether pickle support is usual for C++ extensions functions - extension methods defined using CPython documentation are indeed pickleable. See doc for more details. Further, simple.func should remain a function of the simple module. Pycxx wrongly injects it...

  • Created ticket #42 on PyCXX Python-C++ Connection

    Extension methods are not pickleable in Python 3

View All

Personal Data

Username:
rsaim
Joined:
2019-05-27 13:02:06

Projects

  • No projects to display.

Personal Tools