Start up time

10 views
Skip to first unread message

werner

unread,
Dec 28, 2011, 4:27:57 AM12/28/11
to pypu...@googlegroups.com
Hi Oliver,

First of all I hope you have a nice holiday season and I like to wish
you all the best for 2012.

I am doing a little bit of profiling for the start up time of a little
demo app I did with Mike D. and noted that the "import
pubsub.setupkwargs" is very slow.

Here the import I do:

import logging
log = logging.getLogger(__package__)
log.debug("start pub")
try:
import pubsub.setupkwargs
log.debug("setup kwargs")
from pubsub import pub
log.debug("import pub")
except ImportError:
import wx.lib.pubsub.setupkwargs
from wx.lib.pubsub import pub
log.debug("pub imported")

And this is the log I get:

2011-12-28 10:22:25,414 - mlsrc.controllers - DEBUG - base.py - 9 - wx
imported
2011-12-28 10:22:26,618 - mlsrc.controllers - DEBUG - base.py - 12 -
models imported
2011-12-28 10:22:26,648 - mlsrc - DEBUG - mypub.py - 30 - start pub
2011-12-28 10:22:29,273 - mlsrc - DEBUG - mypub.py - 33 - setup kwargs
2011-12-28 10:22:29,321 - mlsrc - DEBUG - mypub.py - 35 - import pub
2011-12-28 10:22:29,321 - mlsrc - DEBUG - mypub.py - 39 - pub imported
2011-12-28 10:22:29,351 - mlsrc - DEBUG - mypub.py - 42 - topics imported
2011-12-28 10:22:29,351 - mlsrc - DEBUG - mypub.py - 45 - topic setup

As you can see it takes about 2.5 seconds. Is there anything one can do
about this?

Werner

werner

unread,
Dec 28, 2011, 6:04:03 AM12/28/11
to pypu...@googlegroups.com
Did a bit more digging, it seems to be the import of
"pubsub.setupkwargs" and checking how the Python path was setup at that
point I noticed that I had two entries which potentially would resolve.

Cleaning it up resolved this, but I am a bit surprised as I always
thought it was the first one in the path would get imported, i.e. it
wouldn't search any further, which means I can't really explain why it
was slow to start with.

Werner

oliver

unread,
Dec 28, 2011, 9:35:19 AM12/28/11
to pypu...@googlegroups.com
On Wed, Dec 28, 2011 at 6:04 AM, werner <wbr...@free.fr> wrote:
On 12/28/2011 10:27 AM, werner wrote:
Hi Oliver,

First of all I hope you have a nice holiday season and I like to wish you all the best for 2012.

I am doing a little bit of profiling for the start up time of a little demo app I did with Mike D. and noted that the "import pubsub.setupkwargs" is very slow.

...

As you can see it takes about 2.5 seconds.  Is there anything one can do about this?

Did a bit more digging, it seems to be the import of "pubsub.setupkwargs" and checking how the Python path was setup at that point I noticed that I had two entries which potentially would resolve.

Cleaning it up resolved this, but I am a bit surprised as I always thought it was the first one in the path would get imported, i.e. it wouldn't search any further, which means I can't really explain why it was slow to start with.

Hi Werner, same wishes to you! Just curious, what was second path entry pointing to, a different version of pubsub? I'm similarly puzzled that this would have anything to do with it, but hey, problem solved! I know that one thing that can make a big difference is if pubsub is installed as an egg in zip format rather than folder format. Make sure you install egg (if that's what you use) as folder by adding the -Z switch to easy_install. Cheers, 

Oliver

werner

unread,
Dec 28, 2011, 11:46:15 AM12/28/11
to pypu...@googlegroups.com
On 12/28/2011 03:35 PM, oliver wrote:


On Wed, Dec 28, 2011 at 6:04 AM, werner <wbr...@free.fr> wrote:
On 12/28/2011 10:27 AM, werner wrote:
Hi Oliver,

First of all I hope you have a nice holiday season and I like to wish you all the best for 2012.

I am doing a little bit of profiling for the start up time of a little demo app I did with Mike D. and noted that the "import pubsub.setupkwargs" is very slow.

...
As you can see it takes about 2.5 seconds.  Is there anything one can do about this?

Did a bit more digging, it seems to be the import of "pubsub.setupkwargs" and checking how the Python path was setup at that point I noticed that I had two entries which potentially would resolve.

Cleaning it up resolved this, but I am a bit surprised as I always thought it was the first one in the path would get imported, i.e. it wouldn't search any further, which means I can't really explain why it was slow to start with.

Hi Werner, same wishes to you! Just curious, what was second path entry pointing to, a different version of pubsub?
Yes, and on top it was the same version just in a different base folder, e.g.

v1/mlsrc/pubsub
v2/mlsrc/pubsub

and the path would be:

whatever\dev\v1
whatever\dev\v2


I'm similarly puzzled that this would have anything to do with it, but hey, problem solved!
yeap, not going to have a sleepless night over it - will just keep in mind and then maybe do a bit more research on it.

I know that one thing that can make a big difference is if pubsub is installed as an egg in zip format rather than folder format. Make sure you install egg (if that's what you use) as folder by adding the -Z switch to easy_install.
Good to know, anyhow I always do use -Z with easy_install as I like to have easy access to the content.

Currently all is in folders, but vX/mlsrc is a package and for development use (for import stuff) I use "setup.py develop" which creates a file in site-packages called "mlsrc.egg-link" which just points to "v1" folder which in turn has a "mlsrc.egg-info" folder with some text files pointing to the top level package etc.

Werner
Reply all
Reply to author
Forward
0 new messages