This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ferringb
Recipients ferringb
Date 2009-12-29.08:07:34
SpamBayes Score 3.0910274e-12
Marked as misclassified No
Message-id <1262074061.97.0.349318449782.issue7594@psf.upfronthosting.co.za>
In-reply-to
Content
Currently, shlex.shlex's internal read_token is a bit of a nasty mess to
follow and pretty poorly performant.

The refactoring I'll be attaching essentially inverts the state machine
approach read_token uses- instead, converting it over to a more
procedural set of loops.  The benefits of this is that it's far, far
easier to track what the code is actually doing and the performance goes
up fairly drastically via tightening the various for loops (for example,
if doing quoting, you only care about escapes and the terminating quote-
thus a loop there).

End result, the refactored code actually has whitespace in it and still
is shorter- specifically the tokenenizer was converted into a generator
to preserve state internally, thus simplifying the code flow immensely.

Beyond that, this should still be api compatible... and is 2x faster,
passing tests.

Note this patch is cut against 2.6.4; assuming folks are happy w/ the
general approach, I'll rebase it to py3k trunk.

From there, I'd be willing to tackle the other shlex issues where
applicable, but personally... not w/out the refactoring base, since that
state machine is a pita to trace out.
History
Date User Action Args
2009-12-29 08:07:42ferringbsetrecipients: + ferringb
2009-12-29 08:07:41ferringbsetmessageid: <1262074061.97.0.349318449782.issue7594@psf.upfronthosting.co.za>
2009-12-29 08:07:39ferringblinkissue7594 messages
2009-12-29 08:07:38ferringbcreate