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

Ville M. Vainio vivainio at gmail.com
Thu Nov 23 13:06:01 CST 2006


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?

-- 
Ville M. Vainio - vivainio.googlepages.com
blog=360.yahoo.com/villevainio - g[mail | talk]='vivainio'


More information about the IPython-dev mailing list