Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #18624

Re: how to get id(function) for each function in stack?

From Lie Ryan <lie.1296@gmail.com>
Subject Re: how to get id(function) for each function in stack?
Date 2012-01-07 11:17 +1100
References <1002d4cd-6cfe-4b79-917f-361a06ffd215@a11g2000vbz.googlegroups.com> <mailman.4490.1325874536.27778.python-list@python.org> <9f8a8fd4-3541-4f9b-a887-3d10524de8f1@t30g2000vbx.googlegroups.com> <CALwzid=wSK6FRGjfe1_O-zVo2g1sAji7a1dVYRnJv6MewmbNoA@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.4498.1325895612.27778.python-list@python.org> (permalink)

Show all headers | View raw


On 01/07/2012 06:50 AM, Ian Kelly wrote:
> On Fri, Jan 6, 2012 at 12:29 PM, dmitrey<dmitrey15@gmail.com>  wrote:
>> Python build-in function sum() has no attribute func_code, what should
>> I do in the case?
>
> Built-in functions and C extension functions have no code objects, and
> for that reason they also do not exist in the stack.  There is no way
> to find sum() in the Python stack, because it isn't there.

a practical solution to this issue is to wrap the C functions in Python 
functions. You lose some speed but that might be an acceptable tradeoff 
in some situations (especially if you're only wrapping when debugging).

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

how to get id(function) for each function in stack? dmitrey <dmitrey15@gmail.com> - 2012-01-06 10:02 -0800
  Re: how to get id(function) for each function in stack? Ian Kelly <ian.g.kelly@gmail.com> - 2012-01-06 11:28 -0700
    Re: how to get id(function) for each function in stack? dmitrey <dmitrey15@gmail.com> - 2012-01-06 11:29 -0800
      Re: how to get id(function) for each function in stack? Ian Kelly <ian.g.kelly@gmail.com> - 2012-01-06 12:50 -0700
      Re: how to get id(function) for each function in stack? Dave Angel <d@davea.name> - 2012-01-06 14:56 -0500
      Re: how to get id(function) for each function in stack? Ian Kelly <ian.g.kelly@gmail.com> - 2012-01-06 13:37 -0700
      Re: how to get id(function) for each function in stack? Lie Ryan <lie.1296@gmail.com> - 2012-01-07 11:17 +1100
      Re: how to get id(function) for each function in stack? Robert Kern <robert.kern@gmail.com> - 2012-01-07 10:39 +0000
  Re: how to get id(function) for each function in stack? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-01-07 00:54 +0000

csiph-web