Harry Spier wrote at 02/07/2012 08:05 PM:
I have Python programs which convert Indian language book length etexts from one transliteration scheme to another so I'm calling the Python replace function hundreds of thousands of times per e-text and doing multiple replaces with each call.
What about doing all these substitutions in a single pass of reading the input?
You could do it by hand, using reading primitives and/or perhaps using regexps just to tokenize. Or you could try using the regexp engine more, perhaps by programmatically assembling a single regexp that matches any of your terms to replace, and then doing a table lookup to find the substitution.
I'd like to convert these programs to Racket, but using regular expressions might be too slow. Is writing a C foreign function. extension my only alternative or is there such a function in some Racket package..
A clever implementation in pure Racket code might be faster than a less-clever implementation in C.
-- http://www.neilvandyke.org/ ____________________ Racket Users list: http://lists.racket-lang.org/users