durusmail: quixote-users: Illegal Python Names cookbook recipe
Illegal Python Names cookbook recipe
2004-04-05
2004-04-05
2004-04-05
Bug fixes (was: Illegal Python Names cookbook recipe)
2004-04-07
2004-04-07
Bug fixes (was: Illegal Python Names cookbookrecipe)
2004-04-07
Patches for .7a3
2004-04-07
Re: Patches for .7a3
2004-04-08
StaticFile is broken (Quixote-0.7a3, scgi-1.2a2, Apache/1.3.27, FreeBSD 4.7)
2004-04-08
Re: Patches for .7a3
2004-04-21
2004-04-21
2004-04-06
2004-04-06
2004-04-06
2004-04-06
2004-04-06
2004-04-06
2004-04-06
2004-04-07
2004-04-07
2004-04-07
2004-04-07
2004-04-07
2004-04-07
2004-04-07
Re: Illegal Python Names cookbook recipe
2004-04-07
2004-04-07
2004-04-07
2004-04-07
2004-04-07
2004-04-07
2004-04-07
2004-04-07
2004-04-07
2004-04-07
2004-04-07
2004-04-07
2004-04-08
2004-04-07
2004-04-07
2004-04-07
2004-04-06
2004-04-05
2004-04-05
2004-04-05
Re: R: [Quixote-users] Illegal Python Names cookbook recipe
2004-04-06
Illegal Python Names cookbook recipe
Daniele Varrazzo
2004-04-06
> 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.



reply