Solve a Debate

Reedick, Andrew jr9445 at ATT.COM
Fri Feb 15 13:09:37 EST 2008


> -----Original Message-----
> From: python-list-bounces+jr9445=att.com at python.org [mailto:python-
> list-bounces+jr9445=att.com at python.org] On Behalf Of nexes
> Sent: Friday, February 15, 2008 11:25 AM
> To: python-list at python.org
> Subject: Solve a Debate
> 
> Alright so me and my friend are having argument.
> 
> Ok the problem we had been asked a while back, to do a programming
> 
> He declared an array and assigned the number of days in a month to its
> own element in an array. Now
> I realise that in this example it would not make a difference in terms
> of efficiency, but it is my belief that if
> there is more data that needed to be assigned(i.e. a couple megs of
> data) it would be simpler (and more efficient) to
> do a compare rather then assigning all that data to an array, since
> you are only going to be using 1 value and the rest
> of the data in the array is useless.
> 
> What are everyone else's thoughts on this?


Efficient how?  

Looking up the data in a array would probably be faster (look-up tables
normally are.)  

You could make the array efficient by using pointers, gaining both space
and time efficiency.  Mon[1] and mon[3] ... would point to 31.

The array can also just be collection of pointers to the multi-megabyte
objects on disk.  Most languages have modules letting you maintain an
index in memory that points to data on disk.

If the array is static or otherwise only loaded once into memory at
startup, and you have plenty of memory and patience, then who cares if
it is inefficient?  Simple solutions are normally faster to implement.
It's not often that you need to spend three days to save three seconds.

Then there's debug and change efficiency.  An array lookup is simple to
understand and thus less prone to bugs.  It can also be easier to change
a single array element than to change a complicated formula or a cluster
of nested if-then-else statements.



*****

The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA625





More information about the Python-list mailing list