Auto-promotion now occurs in only two cases: when we start the compiler and when we expand a macro. It's fully recursive so even a non-model nested in a model will be promoted.
This change fixes some regressions induced by the stricter type checks of the pattern-matching compiler.
_stdlib is a global variable, so core modules could use it, contrary to our intention, so long as they happened to be compiled after a non-core module. I've added a compiler attribute to track whether we can use _stdlib.
This fix exposed some cases where hy.core.shadow tried to use a core function, so I fixed those.
I've also added an `if not _stdlib` to `load_stdlib` so that we only bother to actually load _stdlib once.
I wasn't able to observe a meaningful performance improvement from it, and it requires some file I/O. Here are the times, in seconds, I observed on my ThinkPad T450s with Python 3.6 and Ubuntu 18.04:
test 1 test 2
master 8.96 2.59
this change 8.88 2.62
Test 1 is the total time from:
$ time dash -c 'git clean -dfx && pip install -e . && pytest --ignore tests/test_bin.py'
Test 2 is pytest's reported total time from a subsequent:
$ pytest --ignore tests/test_bin.py
This is preventing Hy from installing.
Closes#1599#1601 would make this moot, but fixing it is the more conservative change. Pick one or the other. This `botsbuildsbots` doesn't do anything important. It's just one of our Easter eggs.
This copying is what keeps all the mutating code in the compiler methods (e.g., `expr.pop(0)`) from breaking cases in which Hy model objects are compiled more than once or inspected after compilation.
It's rarely useful, because it catches all exceptions, but it doesn't let you do anything other than return `None`. You can still get the same effect with `(except [])`.
HyKeywords are no longer an instances of string with a particular
prefix, but a completely separate object.
This means keywords no longer trip isinstance str checks, adding a
little bit of type safety to the compiler.
It also means that HyKeywords evaluate to themselves.
Closes#1352