Skip to content
Commit 997f6f6a authored by Matt Wala's avatar Matt Wala
Browse files

Convert all experiments to use code generation; make generated functions picklable.

parent e1e2505f
Loading
Loading
Loading
Pipeline #282 passed with stage
Loading
  • Author Maintainer

    Neat. I was not aware of this. I don't think that's the first time I've re-invented something that you first wrote.

    It would be nice to be able to use pymbolic.compiler instead of my giant hack, but currently there are two issues:

    • compile() doesn't like variables like <dt>
    >>> from pymbolic import compile, var
    >>> compile(var("<dt>"))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/local/lib/python2.7/site-packages/pymbolic/compiler.py", line 117, in __init__
        self._compile()
      File "/usr/local/lib/python2.7/site-packages/pymbolic/compiler.py", line 141, in _compile
        self.__call__ = eval(func_s, ctx)
      File "<string>", line 1
        lambda <dt>: <dt>
               ^
    SyntaxError: invalid syntax
    • compile() doesn't like variables that are also keywords
    >>> compile(var("lambda"))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/local/lib/python2.7/site-packages/pymbolic/compiler.py", line 117, in __init__
        self._compile()
      File "/usr/local/lib/python2.7/site-packages/pymbolic/compiler.py", line 141, in _compile
        self.__call__ = eval(func_s, ctx)
      File "<string>", line 1
        lambda lambda: lambda
                    ^
    SyntaxError: invalid syntax
  • I'm also not sure how well it deals with numpy arrays. Given that the purpose is to speed things up, we probably don't want to run a subst to get rid of those var names. Maybe an optional variable-renaming dict is what the doctor ordered?

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment