Python

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Choice creation is slow?

    6 answers - 985 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    Hi everyone,
    I have a screen that has lots of widgets on it, and the Choice widgets are taking much longer to create than the other widgets:
    choices=["1 second", "5 secs", "10 secs", "15 secs", "20 secs"]
    ctrlList = []
    prevTime = time.time()
    for loopidx in xrange(100):
    ctrlList.append(wx.Choice(parent, -1, choices=choices))
    print time.time() - prevTime
    Now with 1 string (e.g. ["1 second"]) this takes .2 seconds, with 3 strings, .34 secs, with 5 strings, .47 seconds. So you can imagine what the startup time is for hundreds of Choice widgets! Now I was hoping for fast performance from wxPython, the other widgets are about three times faster, but that's still not fast!
    But the Choice widgets are my main problem, I have lots of them, with lots of strings, and this is kind of a roadblock at this point.
    Any thoughts appreciated,
    Lee
    P.S. This is with wxPython 2.6.3 and Python 2.4.2 on Windows XP
  • No.1 | | 2624 bytes | |

    "Lee Merrill" <justducky (AT) nc (DOT) rr.comwrote:
    Hi everyone,

    I have a screen that has lots of widgets on it, and the Choice
    widgets are taking much longer to create than the other widgets:

    choices=["1 second", "5 secs", "10 secs", "15 secs", "20 secs"]
    ctrlList = []
    prevTime = time.time()
    for loopidx in xrange(100):
    ctrlList.append(wx.Choice(parent, -1, choices=choices))
    print time.time() - prevTime

    Now with 1 string (e.g. ["1 second"]) this takes .2 seconds, with 3
    strings, .34 secs, with 5 strings, .47 seconds. So you can imagine what
    the startup time is for hundreds of Choice widgets! Now I was hoping
    for fast performance from wxPython, the other widgets are about three times
    faster, but that's still not fast!

    But the Choice widgets are my main problem, I have lots of them, with
    lots of strings, and this is kind of a roadblock at this point.

    Any thoughts appreciated,
    Lee

    P.S. This is with wxPython 2.6.3 and Python 2.4.2 on Windows XP

    Paul Johnston recently asked a similar question about 30 choice controls
    with ~1000 entries per control taking around 17 seconds to create. He
    was also using Windows XP (in my experience, the slow creation time does
    not tend to occur on Windows 2k).

    Robin Dunn offered a solution which seems to have solved Paul's problem:
    1. ch = wx.Choice(parent, -1, choices=[])
    2. ch.Freeze()
    3. ch.AppendItems(choices)
    4. ch.Thaw()

    changing your snippet

    choices=["1 second", "5 secs", "10 secs", "15 secs", "20 secs"]
    ctrlList = []
    prevTime = time.time()
    for loopidx in xrange(100):
    wx.Choice(self, -1, choices=choices)
    choices[-1].Freeze()
    choices[-1].AppendItems(choices)
    choices[-1].Thaw()
    print time.time() - prevTime

    In running your original snippet on my machine, it took 0.234 seconds.
    Running the changed version above runs in .188 seconds. If instead of
    adding 5 items to 100 controls, you were adding 100 items 1000 controls,
    your original snippet ran 11.44 seconds on my machine, but with the
    .Freeze () and .Thaw(), it ran in 6.35 seconds. You may get more
    significant improvements than I have been getting, if only because win2k
    seems to run faster without .Freeze() and .Thaw() than XP.

    Try .Freeze() and .Thaw() as Robin suggests and get back to us.

    - Josiah

    To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
    For additional commands, e-mail: wxPython-users-help (AT) lists (DOT) wxwidgets.org
  • No.2 | | 992 bytes | |

    Thanks Josiah,

    I did try that and it ran (alas) a bit slower, .59 seconds instead of
    47. This is in the initialization code, before any windows appear, so I
    guess I should expect that Freeze wouldn't make it faster. And even on your
    machine, with the new code, it would be about 5 seconds to come up, instead
    of 10.

    So maybe what I will do is make the pages have fewer items, and have
    more pages, I guess I'm not really stuck, and I will also try this on
    Windows 2000 on a machine that has that S at work (this is my little home
    project).

    Thanks,
    Lee

    Robin Dunn offered a solution which seems to have solved Paul's problem:
    1. ch = wx.Choice(parent, -1, choices=[])
    2. ch.Freeze()
    3. ch.AppendItems(choices)
    4. ch.Thaw()

    To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
    For additional commands, e-mail: wxPython-users-help (AT) lists (DOT) wxwidgets.org
  • No.3 | | 1310 bytes | |

    Hi Lee,

    Lee Merrill wrote:

    Hi everyone,

    I have a screen that has lots of widgets on it, and the Choice
    widgets are taking much longer to create than the other widgets:

    choices=["1 second", "5 secs", "10 secs", "15 secs", "20 secs"]
    ctrlList = []
    prevTime = time.time()
    for loopidx in xrange(100):
    ctrlList.append(wx.Choice(parent, -1, choices=choices))
    print time.time() - prevTime

    Did you try:
    AppendItems(self, strings)
    Apend several items at once to the control.

    Now with 1 string (e.g. ["1 second"]) this takes .2 seconds, with 3
    strings, .34 secs, with 5 strings, .47 seconds. So you can imagine
    what the startup time is for hundreds of Choice widgets! Now I was
    hoping for fast performance from wxPython, the other widgets are about
    three times faster, but that's still not fast!

    But the Choice widgets are my main problem, I have lots of them, with
    lots of strings, and this is kind of a roadblock at this point.

    Any thoughts appreciated,
    Lee

    P.S. This is with wxPython 2.6.3 and Python 2.4.2 on Windows XP

    To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
    For additional commands, e-mail: wxPython-users-help (AT) lists (DOT) wxwidgets.org
  • No.4 | | 3199 bytes | |

    ! I tried it again today, and it does work faster to freeze the items
    before adding them to the Choice. error

    So now the snippet runs in .19 seconds, so this may actually be usable. And
    I think I will write a wrapper function for my Choices!

    Thanks again,
    Lee

    Message
    From: "Josiah Carlson" <jcarlson (AT) uci (DOT) edu>
    To: "Lee Merrill" <justducky (AT) nc (DOT) rr.com>;
    <wxPython-users (AT) lists (DOT) wxwidgets.org>
    Sent: Sunday, April 02, 2006 7:39 PM
    Subject: Re: [wxPython-users] Choice creation is slow?

    "Lee Merrill" <justducky (AT) nc (DOT) rr.comwrote:
    Hi everyone,

    I have a screen that has lots of widgets on it, and the Choice
    widgets are taking much longer to create than the other widgets:

    choices=["1 second", "5 secs", "10 secs", "15 secs", "20 secs"]
    ctrlList = []
    prevTime = time.time()
    for loopidx in xrange(100):
    ctrlList.append(wx.Choice(parent, -1, choices=choices))
    print time.time() - prevTime

    Now with 1 string (e.g. ["1 second"]) this takes .2 seconds, with 3
    strings, .34 secs, with 5 strings, .47 seconds. So you can imagine what
    the startup time is for hundreds of Choice widgets! Now I was hoping
    for fast performance from wxPython, the other widgets are about three
    times
    faster, but that's still not fast!

    But the Choice widgets are my main problem, I have lots of them, with
    lots of strings, and this is kind of a roadblock at this point.

    Any thoughts appreciated,
    Lee

    P.S. This is with wxPython 2.6.3 and Python 2.4.2 on Windows XP

    Paul Johnston recently asked a similar question about 30 choice controls
    with ~1000 entries per control taking around 17 seconds to create. He
    was also using Windows XP (in my experience, the slow creation time does
    not tend to occur on Windows 2k).

    Robin Dunn offered a solution which seems to have solved Paul's problem:
    1. ch = wx.Choice(parent, -1, choices=[])
    2. ch.Freeze()
    3. ch.AppendItems(choices)
    4. ch.Thaw()

    changing your snippet

    choices=["1 second", "5 secs", "10 secs", "15 secs", "20 secs"]
    ctrlList = []
    prevTime = time.time()
    for loopidx in xrange(100):
    wx.Choice(self, -1, choices=choices)
    choices[-1].Freeze()
    choices[-1].AppendItems(choices)
    choices[-1].Thaw()
    print time.time() - prevTime

    In running your original snippet on my machine, it took 0.234 seconds.
    Running the changed version above runs in .188 seconds. If instead of
    adding 5 items to 100 controls, you were adding 100 items 1000 controls,
    your original snippet ran 11.44 seconds on my machine, but with the
    Freeze () and .Thaw(), it ran in 6.35 seconds. You may get more
    significant improvements than I have been getting, if only because win2k
    seems to run faster without .Freeze() and .Thaw() than XP.

    Try .Freeze() and .Thaw() as Robin suggests and get back to us.

    - Josiah

    To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
    For additional commands, e-mail: wxPython-users-help (AT) lists (DOT) wxwidgets.org
  • No.5 | | 3417 bytes | |

    "Lee Merrill" <justducky (AT) nc (DOT) rr.comwrote:

    ! I tried it again today, and it does work faster to freeze the items
    before adding them to the Choice. error

    So now the snippet runs in .19 seconds, so this may actually be usable. And
    I think I will write a wrapper function for my Choices!

    ! myself. In the snippet I included, the choices are added on
    widget creation as well as between .Freeze() and .Thaw(). Sorry for the
    confusion.

    - Josiah

    Thanks again,
    Lee

    Message
    From: "Josiah Carlson" <jcarlson (AT) uci (DOT) edu>
    To: "Lee Merrill" <justducky (AT) nc (DOT) rr.com>;
    <wxPython-users (AT) lists (DOT) wxwidgets.org>
    Sent: Sunday, April 02, 2006 7:39 PM
    Subject: Re: [wxPython-users] Choice creation is slow?

    "Lee Merrill" <justducky (AT) nc (DOT) rr.comwrote:
    Hi everyone,

    I have a screen that has lots of widgets on it, and the Choice
    widgets are taking much longer to create than the other widgets:

    choices=["1 second", "5 secs", "10 secs", "15 secs", "20 secs"]
    ctrlList = []
    prevTime = time.time()
    for loopidx in xrange(100):
    ctrlList.append(wx.Choice(parent, -1, choices=choices))
    print time.time() - prevTime

    Now with 1 string (e.g. ["1 second"]) this takes .2 seconds, with 3
    strings, .34 secs, with 5 strings, .47 seconds. So you can imagine what
    the startup time is for hundreds of Choice widgets! Now I was hoping
    for fast performance from wxPython, the other widgets are about three
    times
    faster, but that's still not fast!

    But the Choice widgets are my main problem, I have lots of them, with
    lots of strings, and this is kind of a roadblock at this point.

    Any thoughts appreciated,
    Lee

    P.S. This is with wxPython 2.6.3 and Python 2.4.2 on Windows XP

    Paul Johnston recently asked a similar question about 30 choice controls
    with ~1000 entries per control taking around 17 seconds to create. He
    was also using Windows XP (in my experience, the slow creation time does
    not tend to occur on Windows 2k).

    Robin Dunn offered a solution which seems to have solved Paul's problem:
    1. ch = wx.Choice(parent, -1, choices=[])
    2. ch.Freeze()
    3. ch.AppendItems(choices)
    4. ch.Thaw()

    changing your snippet

    choices=["1 second", "5 secs", "10 secs", "15 secs", "20 secs"]
    ctrlList = []
    prevTime = time.time()
    for loopidx in xrange(100):
    wx.Choice(self, -1, choices=choices)
    choices[-1].Freeze()
    choices[-1].AppendItems(choices)
    choices[-1].Thaw()
    print time.time() - prevTime

    In running your original snippet on my machine, it took 0.234 seconds.
    Running the changed version above runs in .188 seconds. If instead of
    adding 5 items to 100 controls, you were adding 100 items 1000 controls,
    your original snippet ran 11.44 seconds on my machine, but with the
    .Freeze () and .Thaw(), it ran in 6.35 seconds. You may get more
    significant improvements than I have been getting, if only because win2k
    seems to run faster without .Freeze() and .Thaw() than XP.

    Try .Freeze() and .Thaw() as Robin suggests and get back to us.
    - Josiah

    To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
    For additional commands, e-mail: wxPython-users-help (AT) lists (DOT) wxwidgets.org
  • No.6 | | 578 bytes | |

    Sun, 2006-04-02 at 14:29 -0500, Lee Merrill wrote:
    Hi everyone,
    P.S. This is with wxPython 2.6.3 and Python 2.4.2 on Windows XP

    Sometimes ago I notice, if I'm not wrong, that there were some
    performances diferences when running on winxp with the classical theme
    or with the xp theme. The classical is faster, and not only with the
    wxChoice control.

    Ricardo

    To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
    For additional commands, e-mail: wxPython-users-help (AT) lists (DOT) wxwidgets.org

Re: Choice creation is slow?


max 4000 letters.
Your nickname that display:
In order to stop the spam: 7 + 7 =
QUESTION ON "Python"

EMSDN.COM