On Thursday, March 24, 2016 at 2:03:58 PM UTC-4, BartC wrote: > On 24/03/2016 17:13, Ned Batchelder wrote: > > On Thursday, March 24, 2016 at 12:12:55 PM UTC-4, BartC wrote: > >> On 24/03/2016 15:30, Ned Batchelder wrote: > >>> On Thursday, March 24, 2016 at 9:51:11 AM UTC-4, Steven D'Aprano wrote: > >>>> You know what is missing from this conversation? > >>>> > >>>> For one of Bart's critics to actually show faster code. > >>>> > >>>> There's plenty of people telling him off for writing unpythonic and slow > >>>> code, but I haven't seen anyone actually demonstrating that Python is > >>>> faster than his results show. > >>> > >>> As I mentioned before, I'm happy to explain the fuller Python way to > >>> write code, but I don't think Bart wants to learn it, because he is > >>> focused on a different goal than, "write real Python code the best > >>> possible way." > >>> > >>> Here, for example, is a real lexer for JavaScript that I wrote: > >>> https://bitbucket.org/ned/jslex/src > >>> > >> > >> Thanks for that. > >> > >> I don't have any JS to throw at it, but it seems happy with any bits of > >> source code or even just text. > >> > >> Using your short driver program (with the prints commented out), and > >> tested with 'bible.txt' as input (ie. mostly English words), then your > >> JS lexer was roughly half the speed of the Python version I linked to > >> last week (with the if-elif chains and working with strings). > > > > I have tried to find your code, but cannot find in the forest of this > > thread. > > Can you provide a link to it online? I would be very interested to > > understand > > the difference in performance. > > This the version I used today: > > http://pastebin.com/dtM8WnFZ >
Thanks. It is faster than mine. The lesson I learned is, if you (I) make regexes too fancy, they are slower than the low-tech way. :) I suspect there is a way to use the re module more efficiently, but I don't have the time at the moment to figure out how. --Ned. -- https://mail.python.org/mailman/listinfo/python-list