Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7934159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:33:37+00:00 2026-06-03T21:33:37+00:00

I was reading through the file methodobject.c, because I’m trying to learn about making

  • 0

I was reading through the file methodobject.c, because I’m trying to learn about making C extensions for Python, when I saw the following code snippet:

PyObject *
PyCFunction_Call(PyObject *func, PyObject *arg, PyObject *kw)
{
    PyCFunctionObject* f = (PyCFunctionObject*)func;
    PyCFunction meth = PyCFunction_GET_FUNCTION(func);
    PyObject *self = PyCFunction_GET_SELF(func);
    Py_ssize_t size;

    switch (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)) {
    case METH_VARARGS:
        if (kw == NULL || PyDict_Size(kw) == 0)
           return (*meth)(self, arg);
        break;

The more I look at

    return (*meth)(self, arg);

the more I realize I don’t understand it. I think it’s returning a pointer to meth, which is a function that takes self (a locally declared pointer) and arg (a pointer passed externally into PyCFunctionCall). However, since it looks to me as though meth & self are allocated on the stack, once PyCFunctionCall exits, they will be freed, which will cause problems for whatever variables they are passed to.

What am I missing here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T21:33:39+00:00Added an answer on June 3, 2026 at 9:33 pm

    It’s returning the return value of meth(self, arg), not meth itself. Note that it’s derferencing the pointer with (*meth), then passing in self and arg to the function at that location.

    So meth(self, arg) will be completely evaluated before the return happens, and no stack variables will be returned.

    Edit: when I say meth(self, arg), I mean the_function_pointed_to_by_meth(self, arg).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Reading through file using ifstream I'm trying to find a way to
I was reading through the Tomcat source code, trying to figure out how the
I've been reading through a few tutorials about css, and I saw two different
I am reading through the source code of indianwebproxy and it uses proxycertificate.ser file
In my MVC application I am trying to open a file for reading through
I am reading .csv file through PHP using fgetcsv(). Now I am able to
Reading through documentation, I found following: 1.9.1 1.8.4 1.8.2 A version of 1.8.2 select
I have been reading through this wonderful website regarding the recommended Python IDEs and
Ok, I'm reading through a file now, line by line. I know each functions
So I'm trying to do something extremely simple, and after reading through forums, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.