[IPython-dev] [patch 1/2] Try to use cProfile module (Python-2.5) instead of old profile.

Kirill Smelkov smelkov at mph1.phys.spbu.ru
Thu Nov 23 15:44:05 CST 2006


On Thu, Nov 23, 2006 at 09:06:01PM +0200, Ville M. Vainio wrote:
> On 11/22/06, Kirill Smelkov <smelkov at mph1.phys.spbu.ru> wrote:
> 
> >rationale: cProfile is faster.
> > try:
> >    import profile,pstats
> > except ImportError:
> >-    profile = pstats = None
> >+    pass
> >+
> >+# cProfile was added in Python2.5
> >+# if present, we use it instead of old profile, because cProfile is faster
> >+try:
> >+    import cProfile as profile
> >+    import pstats
> >+except ImportError:
> >+    pass
> 
> New you import both profile and cProfile, if both exist. That's a bit
> wasteful; why not import cProfile first, and only if that raises
> ImportError import profile?
That's what I originally did (see [patch 2/9], buf Fernando objected, I
can't understand why...

-- 
    Всего хорошего, Кирилл.
    http://landau.phys.spbu.ru/~kirr/aiv/


More information about the IPython-dev mailing list