optimize Namespace

Issue #156 resolved
Michael Bayer
repo owner created an issue

its time to get around to this.

1. the "file" and "module" arguments to <%namespace> become mutually exclusive. one or the other.

2. `Namespace` breaks into `TemplateNamespace`, `ModuleNamespace`, and `Namespace` which still is used if there's no template or module.

3. `getattr` can now be broken down to not require the "has_def()" and "hasattr()" calls, just catch attributeerror and re-raise.

4. more importantly, `getattr` should put the resolved method into `dict`.

5. when we do the lambda *args, kwargs:callable_(context, *args, kwargs), lets use functools.partial . its native

6. inline _get_star(), plus the partial, should speed it up a bit

Comments (1)

  1. Michael Bayer reporter

    the above more or less in 717d8a82e46c761c42192f17a58b185f6f64b48a cff83675deb802e8c2aa78c98dc0e1ce4a179ac1 cb9ebd2288031c96dda349a8eb42bf6bacbec8f1. can't really lose the has_def() and hasattr() calls. some runsnakerun profiling revealed the biggest hit as not using StringIO anymore (4737c269f5658fdab4190504cd5744e95bae1688) and to get rid of that builtin copy (6c06a3270b6fca6d959fff4c81cf932e17a475d2). we're within 10% of jinja2 in that particular test now.

  2. Log in to comment