[PATCH] Re: Import cProfile module before falling back to profile
Sebastian at SSpaeth.de
Tue Dec 7 09:23:21 GMT 2010
On Mon, 6 Dec 2010 18:23:10 +0100, Nicolas Sebrecht <nicolas.s-dev at laposte.net> wrote:
> On Mon, Dec 06, 2010 at 01:19:31PM +0100, Sebastian Spaeth wrote:
> > diff --git a/offlineimap/threadutil.py b/offlineimap/threadutil.py
> > index b516f68..c65700e 100644
> > --- a/offlineimap/threadutil.py
> > +++ b/offlineimap/threadutil.py
> > @@ -148,7 +148,10 @@ class ExitNotifyThread(Thread):
> > if not profiledir: # normal case
> > Thread.run(self)
> > else:
> > - import profile
> > + try:
> > + import cProfile as profile
> > + except ImportError:
> > + import profile
> How do we know which library is currently used?
We don't, but we also don't care. They are identical, as far as the user
is cincerned. cProfile has been added in 2.5 and is much faster.
If the user really wants to find out, he can query profile.__name__
which results in either "cProfile" or "profile".
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 197 bytes
Desc: not available
More information about the OfflineIMAP-project