On 2011-04-04, Alia Khouri <alia_kho...@yahoo.com> wrote: > Nice! I didn't think of that. I guess I could get some > additional performance by taking the re.compile step out of the > function. Thanks for the tip!
I recommend "The Pragmatic Programmer," (Hunt, Thomas) ISBN 978-0201616224 and "The Practice of Programming," (Kernighan, Pike) ISBN 978-0201615869 for more practical tips like this one. As a mostly self-taught programmer, both books helped me immensely. If you're a seasoned pro with a CS degree, you might not find them quite as interesting, though. The second book, especially, does not cover issues relating to large scale software development. As for factoring out re.compile, I believe they are cached by the re module, so you would save the cost of retrieving the cached regex, but not the cost of building it. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list