Python Forum
Embedded Python PyObject_CallObject function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Embedded Python PyObject_CallObject function
#1
  • It appears that PyObject_CallObject() always returns an PyObject pointer event when the Python function does not explicitly return a value or object.
  • Assuming that the call is successful.
  • One example is a parameter setter function.

Can anyone explain what is being returned and how I may make use of it?
Reply
#2
A Python function always returns something. If the function returns via a bare return statement, it actually returns None. From the interactive prompt, return values of None are not shown.

>>> def f():
...   return
... 
>>> f()
>>> x=f()
>>> print(x)
None
Assuming you know the function has no specific return value, there isn't much use for the new reference to None. Since you have a new reference, you must decrement the reference count before discarding it.

casevh
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to run detectron2, as python embedded code in C++, on GPU? hassaniqbal931 3 1,039 Nov-02-2023, 04:45 PM
Last Post: blabling2
  Adding libraries to embedded Python as a ZIP The_Oman 0 1,192 May-05-2023, 04:05 PM
Last Post: The_Oman
Bug Embedded Python Memory Leaks Alexei 1 1,003 Sep-16-2022, 01:15 PM
Last Post: Alexei
  Embedded Python in C++ Xeno 19 3,398 Aug-03-2022, 07:29 AM
Last Post: Gribouillis
  Embedded python fails to compile on Raspberry Pi tryfon 2 3,399 Dec-22-2020, 02:06 PM
Last Post: tryfon
  Can Embedded Python run any shared library on Android ? sprotz 0 2,270 Nov-08-2020, 12:21 PM
Last Post: sprotz
  Passing argument from top-level function to embedded function JaneTan 2 2,204 Oct-15-2020, 03:50 PM
Last Post: deanhystad
  memory leak on embedded python in c++ asdf3721 3 3,333 Jul-16-2020, 06:33 AM
Last Post: Gribouillis
  Trying to implement Python into embedded OS thesurya7 2 2,369 Apr-02-2019, 06:38 PM
Last Post: ebolisa
  Multiple calls to Python interpreter embedded in C++ application yield segmentation f mmoelle1 0 2,795 Mar-21-2019, 08:54 PM
Last Post: mmoelle1

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020