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


Groups > comp.lang.python > #85640

Re: line_profiler: what am I doing wrong?

From Neal Becker <ndbecker2@gmail.com>
Subject Re: line_profiler: what am I doing wrong?
Date 2015-02-13 08:33 -0500
References <mailman.18635.1423613207.18130.python-list@python.org> <54daa1d6$0$12979$c3e8da3$5496439d@news.astraweb.com> <mailman.18639.1423615521.18130.python-list@python.org> <54daada4$0$12998$c3e8da3$5496439d@news.astraweb.com> <mbft93$vk1$1@ger.gmane.org>
Newsgroups comp.lang.python
Message-ID <mailman.18728.1423834414.18130.python-list@python.org> (permalink)

Show all headers | View raw


Robert Kern wrote:

> On 2015-02-11 01:17, Steven D'Aprano wrote:
>> Neal Becker wrote:
>>
>>
>>> To quote from https://pypi.python.org/pypi/line_profiler/
>>>
>>> $ kernprof -l script_to_profile.py
>>> kernprof will create an instance of LineProfiler and insert it into the
>>> __builtins__ namespace with the name profile.
>>
>> Ewww!!!! What a Ruby-esque interface, that makes me sad :-(
> 
> <shrug> This is not a production library. It's a development tool designed to
> help developers shorten the cycle time for investigating these kinds of
> issues. Well, *a* developer; i.e. me. If it helps anyone else, yahtzee!
> 
>> And what if you
>> have your own profile global name?
> 
> Then you can pull it out from __builtin__ with a different name and use that
> other name.
> 
>> And *wrong* too. `__builtins__` is a private CPython implementation detail.
>> The way to monkey-patch the built-ins in Python 2 is to inject the object
>> into `__builtin__` (no s), or `builtins` in Python 3.
> 
> And indeed that is how it is implemented. Referring to that namespace as the
> "`__builtins__` namespace" isn't *wrong*. It may mislead you into thinking
> I've implemented it one particular way, if you are desperate to find a nit to
> pick.
> 
>> Seeing as
>> line_profiler is written in C, perhaps the author (Robert Kern) doesn't
>> care about supporting Jython or IronPython,  but there may be Python
>> implementations (PyPy perhaps?) which can run C code but don't have
>> __builtins__.
> 
> Indeed, I do not care about any of them. PyPy does not implement CPython's
> tracing API:
> 
> 
https://bitbucket.org/pypy/pypy/src/2b2163d65ee437646194a1ceb2a3153db24c5f7e/pypy/module/cpyext/stubs.py?at=default#cl-1286
> 

Hi Robert, any idea why line_profiler is not working?  I've used it fine in the 
past.

-- 
-- Those who don't understand recursion are doomed to repeat it

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


Thread

line_profiler: what am I doing wrong? Neal Becker <ndbecker2@gmail.com> - 2015-02-10 19:06 -0500
  Re: line_profiler: what am I doing wrong? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-11 11:27 +1100
    Re: line_profiler: what am I doing wrong? Neal Becker <ndbecker2@gmail.com> - 2015-02-10 19:45 -0500
      Re: line_profiler: what am I doing wrong? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-11 12:17 +1100
        Re: line_profiler: what am I doing wrong? Robert Kern <robert.kern@gmail.com> - 2015-02-11 15:42 +0000
          Re: line_profiler: what am I doing wrong? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-12 10:02 +1100
        Re: line_profiler: what am I doing wrong? Neal Becker <ndbecker2@gmail.com> - 2015-02-13 08:33 -0500

csiph-web