Re: dict is really slow for big truck



Scott David Daniels wrote:
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()

From the explanation it's clear that the .strip() is unnecessary.
.



Relevant Pages

  • Re: dict is really slow for big truck
    ... arr = line.strip.split ... this formulation around various places. ... When does line.strip.splitever differ from line.split? ... <explanation of what split does> ...
    (comp.lang.python)
  • Re: Goedel - interesting problem?
    ... Acme, in all sincerity, Torkel's formulation is about as accurate a ... Dolan's "explanation" is really quite bad. ...
    (sci.logic)
  • Re: Prefered resistor range
    ... Fred Bloggs wrote: ... > Well- I am here to tell you that 1) the explanation about color contrast ... > simple formulation to calculate precisely every single value to three ...
    (sci.electronics.design)
  • Re: .each do |foo, bar| what does bar do?
    ... Thanks for the explanation on the &block question. ... I'm still not understanding what the problem was with my example. ... hash.each {|arr| ...} ...
    (comp.lang.ruby)
  • Re: Leeds Vandalism
    ... I will stick with my explanation of why I think it entirely ... we'll have to agree to differ. ... A danger only to people behaving in a grossly illegal manner. ...
    (uk.railway)

Loading