An efficient split function

Sion Arrowsmith siona at chiark.greenend.org.uk
Mon May 10 11:54:52 EDT 1999


In article <wy3e15x8sa.fsf at wiggum.dejanews.com>,
William S. Lear <rael at see.sig> wrote:
>Previous tests of mine comparing the getline() version that works
>with C++ strings and that which works with character arrays showed me
>that the latter was much faster, albeit less flexible.

My experience with string v. char* getline() in a real-world log-
file handler is that the speed up is insignificant compared to the
processing of the data, and that the char* version has big
problems unless you can absolutely guarantee a maximum line-
length on your input. Your code doesn't have the buffer-overrun
problems the stuff I was cleaning up did, but it is going to lose
data on lines >1k. (Q. Who'd give you an input line that long? A.
Never underestimate the perversity of users.)

-- 
\S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
  ___  |  "Frankly I have no feelings towards penguins one way or the other"
  \X/  |    -- Arthur C. Clarke
       |  If music be the food of love, bring me a doggie bag.




More information about the Python-list mailing list