[Tutor] fine in interpreter, hangs in batch

Jerry Hill malaclypse2 at gmail.com
Mon Mar 19 20:52:37 CET 2007


On 3/19/07, Switanek, Nick <nswitanek at stanford.edu> wrote:
> Thanks very much for your help.
>
> It appears that the step that is taking a long time, and that therefore
> makes me think that the script is somehow broken, is creating a
> dictionary of frequencies from the list of ngrams. To do this, I've
> written, for example:

Well, if you're guessing which part of your code is slow, you should
profile your code so you can stop guessing.  Python has some very
useful built in profiling tools, documented here:
http://docs.python.org/lib/profile.html

Take a look at the "Instant User's Manual", which should be enough to
get you started. Once you can see exactly which parts of your code are
taking the longest, then you'll know what the best targets are for
optimization.

-- 
Jerry


More information about the Tutor mailing list