> The performance impact should be negligible. Instead of 'component
> in container._q_exports', we would have:
>
> for val in exports:
Sorry, i don't know the internals of quixote compiling and traversal,
but a linear scan on the _q_exports list sounds a bit strange to me.
Wouldn't it be better to obtain a dict mapping sometimes (but once -
don't know where)?
from types import StringTypes, TupleType
def get_exports_dict(L):
d = {}
for i in L:
if type(i) in StringTypes:
d[i] = i
elif type(i) is TupleType and len(i) == 2:
d[i[0]] = i[1]
else:
raise TypeError(
"Only strings or 2-tuples allowed in _q_exports. %s found
instead."
% repr(i))
return d
[...] do once per container:
container._q_exports_dict = get_exports_dict(container._q_exports)
[...] to use the mapping
container._q_exports_dict.get(component)
> For a reasonably short exports list my workstation can do that about
> 300000 times a second. Thank you AMD. :-)
I never benchmarked Quixote, but i think the traversal is not called
once per page, but once per component per url, and if you have many
images in a _q_exports i guess those urls will be parsed too. Exports
may not be "reasonably short"... I may be wrong but maybe it worth
a think. It would change some internals but not user's pages.