web2py/web2py — pull request #153 by niphlod (2013-07-31 22:12:07+00:00)
Title: call to build_parsemap() on __init__ instead of at every select()

hard to give a consistent figure, but for ~10 select()s the speedup is ~3%. Speedup grows with the number of select()s for every request (if DAL is used within a web env) or for every select() done in a single connection (e.g. in a script).

There's a small performance penalty only if the application has a DAL connection but the controller doesn't need any select(). Anyway, given that in that case the time to build one-time the parsemap dict is the same one saved for each and every select() operation, I think that this behaviour (calling on __init__) is better than calling it in parse() for the majority of the applications.

This commit limits users fiddling with the undocumented build_parsemap() function, because it's not possible to specify a custom parsemap after connecting to a database. Given that such users are pretty advanced, they can circumvent the limit overriding the adapter with a custom build_parsemap().