From: Tony Cappellini [mailto:tony@tcapp.com]
I was going through the walkthrough/tutorials for PythonCard.
While I'm very interested in learning some GUI for Python, I'm very
disappointed to see that the most simplest
tutorial (minimal.py) for PythonCard takes nearly 10 seconds to
load, on an
800MHZ Windows 2000 machine.
(to the best of my knowledge, nothing else was running at the time)
I realize Python is interpreted, and that it executes some
things quicker
in 2.3, but if a gui takes this long to load the smallest
application, then
is it really worth using ?
Is there anything that can be done to minimize this startup time ?
PythonCard does have to jump through more hoops than the smallest wxPython
app, but your startup time seems quite long even for an older machine with a
slow hard drive. That is certainly longer than it takes for a cold startup
on my crufty PIII notebook which has a really slow hard disk.
The very first time PythonCard runs it will create a pythoncard_config dir
and copy some files to that dir. Like any Python app, the first time modules
are imported, there will be some overhead for creating the .pyc files. If
you use any of the debug tools, there is also some overhead in loading
PyCrust...
The biggest files that have to be loaded from disk are wxmsw24h.dll and
wxc.pyd which total over 5MB, but all wxPython programs on Windows have to
deal with that and the other platforms have libs to load too. As of wxPython
2.4.1.2, there is also the overhead of the new wx namespace creation.
Unless you have very little RAM, once you've run something, subsequent loads
should also be much faster.
But in the end if PythonCard loads too slowly for you then of course you
should probably not use it. I've included a pretty minimal wxPython app
below that you can use as a baseline for comparing load time to any other
wxPython based app or framework.
ka
···
---
from wxPython import wx
class MyApp(wx.wxApp):
def OnInit(self):
frame = wx.wxFrame(None, -1, "minimal", size=(200, 200))
panel = wx.wxPanel(frame, -1)
frame.Show(1)
self.text1 = wx.wxTextCtrl(panel, -1, pos=(0, 30))
self.btn = wx.wxButton(panel, -1, "set text")
wx.EVT_BUTTON(panel, self.btn.GetId(), self.OnMouseClick)
self.SetTopWindow(frame)
return 1
def OnMouseClick(self, evt):
self.text1.SetValue('42')
app = MyApp(0)
app.MainLoop()