Questions tagged [pyobject]

This is a type which contains the information Python needs to treat a pointer to an object as an object.

Definition

All object types are extensions of this type. This is a type which contains the information Python needs to treat a pointer to an object as an object. In a normal “release” build, it contains only the object’s reference count and a pointer to the corresponding type object. It corresponds to the fields defined by the expansion of the PyObject_HEAD macro.

Documentation

Common Object Structures

70 questions
2
votes
1 answer

C++ to numpy and back to C++, tuple PyObject

I am implementing a Visual C++ code (MS VStudio 2013) that acquires an image from a camera, processes the image, sends pre-processed data (an array 2 or more doubles) to python through a PyObject, and gets numpy-processed results back from python (a…
2
votes
2 answers

C++ and Python- checking type of PyObject fails

I'm a bit confused. I'm trying to do some C++ and Python integration, but it's less than straightforward. I'm not using Boost, because I couldn't get Boost::Python to compile properly. But that's another story. Currently, here's what I'm doing in…
Will Tice
  • 434
  • 4
  • 17
1
vote
1 answer

Issue with the dequeue function in the custom class

I am building a RingBuffer class for my module. However, I am facing some issues with the dequeue function. When I enqueue/dequeue integers, everything is fine. When I enqueue a list, the first dequeue operation returns an empty list instead of the…
Sekomer
  • 688
  • 1
  • 6
  • 24
1
vote
1 answer

can't pass less or more than 2 args for methods passing to array of PyMethodDef

I am following this doc on extending c++ to python. As far as what was demonstrated there, the PyObject *spam_system(PyObject *self, PyObject *args) {...} works fine when passing to array of PyModuleDef but if I want to add more args to spam_system,…
PatXio
  • 129
  • 2
  • 16
1
vote
1 answer

How do I use PyObject* args in C python extension?

I am trying to make a simple extension in C that should be able to extend python code . I found that code on https://github.com/munirhossain/py_c_extension #include // Function 1: A simple 'hello world' function static PyObject*…
1
vote
0 answers

Pybind11 exception with tensorflow 2.2 env in python cpp communication

Below is CPP calling python file source code for a reference. int main(int argc, char *argv[]) { PyObject *pName, *pModule, *pFunc; PyObject *pArgs, *pValue; int i; string pythonFunction = "sample_fun"; string pythonFile = "sample" string…
1
vote
1 answer

PyImport_Import fails silently and execution of code stops without errors

I'm trying to implement aprecision index in a Turbodecode algorythm written in C. After finding a way to do that i'm trying to embedd a python function in order tu use matplotlib and plot a graph showing the precision of the decoder. Problem is…
1
vote
2 answers

Using Julia PyCall, to use matplotlib.pyplot, inside a Julia module

I'm using MacOS 10.13.6, High Sierra From terminal, julia -- version yields julia version 1.0.1 From terminal, python --version yields Python 2.7.15 Running scripts from terminal I have a small Julia script that works after a fix that I found from…
Charles
  • 947
  • 1
  • 15
  • 39
1
vote
1 answer

Passing c variables to python and back

I am using the PyObject functionality to call c functions, and return Py_BuildValue("theTypeToConvert", myCVariable); to return things back to my python program, this all works fine. However I have a custom C type extern HANDLE pascal how do I…
user886045
1
vote
0 answers

boost::python PyObject implicit cast

I have C++ classes that handle callbacks for both C++ and python. for instance: typedef void (*SomeCppCallback)(int count); class Callback { public: Callback(PyObject* callable); Callback(SomeCppCallback callable); } And some…
o.z
  • 1,086
  • 14
  • 22
1
vote
0 answers

How do I pass a populated c structure to python (without ctypes)

How can I pass a c structure to python without using ctypes ? I have a pointer to a stats_res_t structure that I'm trying to return to python. I'm trying something along the lines of PyObject* pyobject_get_system_stats(PyObject *self, PyObject…
nkshirsa
  • 11
  • 3
1
vote
1 answer

Create a PyObject with attached functions and return to Python

I wonder how I can create a PyObject in C++ and then return it to Python. Sadly the documentation is not very explicit about it. There is no PyObject_Create so I wonder whether allocating sizeof(PyObject) via PyObject_Malloc and initializing the…
abergmeier
  • 13,224
  • 13
  • 64
  • 120
1
vote
1 answer

finding out how many arguments a PyObject method needs

We can extract a PyObject pointing to a python method using PyObject *method = PyDict_GetItemString(methodsDictionary,methodName.c_str()); I want to know how many arguments the method takes. So if the function is def f(x,y): return x+y how do…
jkcl
  • 2,141
  • 3
  • 16
  • 19
1
vote
0 answers

Error to compile file PyObject (Gtk ) with Pydev

I'm build application with pyobject (gtk) in Pydev , but i'm try to create a window the following way: Class Ventana from gi.overrides import Gtk class Ventana( Gtk.Window ): def __init__( self,titulo ): …
Cristian
  • 1,480
  • 5
  • 32
  • 65
0
votes
1 answer

Python and Gtk+3 Entry problems

Greetings guys and girls! I am new in programming Gtk+ and need a "decent" opensource twitter client and I can't find one, so I'm developing one that 'll be opensource. I'm using Gtk+3 and Python (PyGObject not PyGtk), and I'm having 2 problems with…
pharaoh
  • 313
  • 1
  • 3
  • 15