To Tuple or to Map?
Clark C . Evans
cce at clarkevans.com
Thu Jan 24 13:49:28 EST 2002
I've got a question. In my application I deal with many
tables (some of them very big) where each row in the table
has many cells. I have a question as to how I should model
cells. Should they be maps or tuples? If they are maps,
then I'd do row['colname'] to access the value and if they
are tuples, I'd do row[nColName] where nColName is an integer.
Since all of my rows ar relatively standard, I'm leaning
toward using tuples and integers. But, I must admit, using
a bunch of maps looks a bit cleaner... So, here is the question:
(a) Does a map have significantly more run-time
overhead than a tuple?
(b) Is there any way to mark a variable (nColName)
as a constant so that the "byte compiler" can
resolve the value to an integer (instead of
requiring an access to the local namespace)
(c) Which technique would you use?
Thanks!
Clark
More information about the Python-list
mailing list