dict is really slow for big truck
Scott David Daniels
Scott.Daniels at Acm.Org
Wed Apr 29 16:07:03 EDT 2009
MRAB wrote:
> Scott David Daniels wrote:
>> Bruno Desthuilliers wrote:
>>> d = {}
>>> for line in open(thefile):
>>> arr = line.strip().split()
>>> d[arr[0]] = arr
>>
>> Sorry, not picking on Bruno in particular, but I keep seeing
>> this formulation around various places.
>> When does line.strip().split() ever differ from line.split()?
> ... <explanation of what split does>
You misunderstand the question. For what values of line is
the following expression False?
line.strip().split() == line.split()
If you know of one, I'd like to hear of it. If not, I assert
that (baring some incredibly over-ambitous optimizer operations)
line.strip().split()
is simply an inefficient (both performance and text) way of saying:
line.split()
--Scott David Daniels
Scott.Daniels at Acm.Org
More information about the Python-list
mailing list