Bill Mill wrote:
> 
> Pentium M 1.8 GHz Windows 2k. Here's the top of the profile results
> for fast and slow on my machine (these won't look decent except in a
> fixed-width font):
> 
<snip profiles>
>
> Interestingly, the test.py:36 line, which takes 45 seconds (!!) in the
> slow version, does not appear at all in the fast profile. I can't
> figure out why - both printed out their data, so template must have
> been called somewhere.
> 

OK, I'm getting somewhere now. When I replace:

template = ("  | %s %s %s | %s %s %s | %s %s %s |\n" * 3).join([" 
+-------+-------+-------+\n"] * 4)

wtih:

template = """   | %s %s %s | %s %s %s | %s %s %s |\n
  | %s %s %s | %s %s %s | %s %s %s |\n
  | %s %s %s | %s %s %s | %s %s %s |\n
  +-------+-------+-------+\n
  | %s %s %s | %s %s %s | %s %s %s |\n
  | %s %s %s | %s %s %s | %s %s %s |\n
  | %s %s %s | %s %s %s | %s %s %s |\n
  +-------+-------+-------+\n
  | %s %s %s | %s %s %s | %s %s %s |\n
  | %s %s %s | %s %s %s | %s %s %s |\n
  | %s %s %s | %s %s %s | %s %s %s |\n
  +-------+-------+-------+\n"""

Then the non-dummy version is faster than the dummy version (very
slightly, presumably because it doesn't need to allocate 28 dummy
variables).

Peace
Bill Mill
bill.mill at gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to