We've been talking this week about ideas for speeding up the parsing of Longs coming out of files or network. The use case is having a large string with embeded Long's and parsing them to real longs. One approach would be to use a simple slice:
<br>long(mystring[x:y]) <br><br>an expensive operation in a tight loop. The proposed solution is to add further keyword arguments to Long (such as):<br><br>long(mystring, base=10, start=x, end=y)<br><br>The start/end would allow for negative indexes, as slices do, but otherwise simply limit the scope of the parsing. There are other solutions, using buffer-like objects and such, but this seems like a simple win for anyone parsing a lot of text. I implemented it in a branch
<span id="st" name="st" class="st">runar</span>-longslice-branch, but it would need to be updated with Tim's latest improvements to long. Then you may ask, why not do it for everything else parsing from string--to which I say it should. Thoughts?
<br clear="all"><br>-- <br>Runar Petursson<br>Betur<br><a href="mailto:runar@betur.net">runar@betur.net</a> -- <a href="http://betur.net">http://betur.net</a><br>