On 17/05/2008, Adam Clarridge <[EMAIL PROTECTED]> wrote:
>  I'm fairly new to Python, and I am not sure whether it would be faster
>  for me to use a Dictionary data type to represent the board
>  (advantages: indices can be strings or tuples, and the dictionary can
>  store different types of data as well, so programming would be easier)
>  or the Numpy array type (don't know much about this, but I have heard
>  Numpy is faster).

Hi Adam,

I believe a general rule of programming is: don't optimize until you
know you need to.  I would advise using dictionaries for simplicity.
If the program turns out slower than you would like, you can use
profiling tools to figure out where in the code it is spending most of
its time.  If this turns out to involve dictionary lookups, you could
then look at changing to Numpy (hint: you could use the timeit module
to benchmark dictionary access against Numpy arrays).  If your program
design is good, the change should be too hard.

http://en.wikipedia.org/wiki/Optimization_(computer_science)#When_to_optimize

-- 
John.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to