Commit Graph

2395 Commits

Author SHA1 Message Date
Kodi Arfer
ad94343e4a Merge pull request #1269 from Kodiologist/bytecode
Automatically read and write bytecode
2017-04-14 13:52:07 -07:00
Kodi Arfer
a87b23b4e8 Check the magic number of bytecode files 2017-04-14 13:38:38 -07:00
Kodi Arfer
36324e9499 Work around a Nose import bug on PyPy 2017-04-14 13:38:38 -07:00
Kodi Arfer
2b11b9be20 Automatically read and write bytecode
Importing or executing a Hy file now loads the byte-compiled version if it exists and is up to date, and if not, the source is byte-compiled after it's parsed.

This change can speed up Hy a lot. Here are some examples comparing run times of the current master (491b474e) to this commit, on my laptop with Python 3.6:

- `nosetests --exclude='test_bin'` goes from 3.8 s to 0.7 s (a 5-fold speedup)
- `hy -c '(print "hello world")` goes from 0.47 s to 0.20 s (a 2-fold speedup)
- Rogue TV's startup goes from 3.6 s to 0.4 s (a 9-fold speedup)

Accompanying changes include:

- `setup.py` now creates and installs bytecode for `hy.core`, `hy.contrib`, and `hy.extra`.
- The `hyc` command under Python 3 now creates bytecode in `__pycache__`, as usual for Python 3, instead of putting the `.pyc` right next to the source file like Python 2 does.

I've removed a test of `hy.extra.anaphoric.a-if` that triggers #1268 when the test file is byte-compiled and then hits some weird `macroexpand` bug or something when I try to work around that—Nose crashes when trying to produce an error message, and I can't seem to replicate the bug without Nose.
2017-04-14 13:38:33 -07:00
Kodi Arfer
7a53fdb180 Fold .coveragerc into setup.cfg 2017-04-14 11:15:58 -07:00
Kodi Arfer
b71962bbaa Remove unused internal fn import_file_to_globals 2017-04-14 11:15:58 -07:00
Kodi Arfer
5eb928356a Overhaul semantics of binary operators (#1261)
I've added shadow versions of many operators that didn't have one. And, I've changed the behavior of various binary operators with more or fewer than 2 arguments to make the shadow and real versions more consistent and to make the behavior more logical in either case. For details, see the additions to NEWS and the new file tests/native_tests/operators.hy, which simultaneously tests shadow and real operators.

Although there are a lot of changes, I've put them all in one commit because they're interdependent.
2017-04-13 19:42:01 -05:00
Kodi Arfer
18acfe6495 Revert the extension of with-decorator to setv
This is no longer necessary now that `defn` always produces a `FunctionDef`.

To compensate, I've made small edits to two contrib modules and reverted a small test change.
2017-04-13 06:36:00 +03:00
Kodi Arfer
7c203abe4d Fix bug with unset __name__ of one-line functions
The bug was a regression that I introduced in #1228.

I've created a new special form named `fn*` that works like the old `fn` (that is, it always creates a `FunctionDef`). Since this is intended only for internal use, like `with*`, I haven't documented it.
2017-04-13 06:36:00 +03:00
Kodi Arfer
491b474e7f Make setv return None for more types of rvalues 2017-04-07 21:21:19 +03:00
Kodi Arfer
286d568959 Fix a crash when tokenizing a single quote 2017-04-07 21:12:17 +03:00
Kodi Arfer
bb9f543246 Merge pull request #1265 from tuturto/repl-doc
Add --repl-output-fn into command line docs
2017-04-01 08:01:43 -07:00
Kodi Arfer
36d09cb194 More documentation of strings and keywords
Currently, HyKeyword is not in fact a subclass of HyString, so I removed that statement.
2017-04-01 08:23:41 +03:00
Tuukka Turto
61daf98111 Merge pull request #1263 from Kodiologist/walk-loop
Fix bug: `loop` replaced strings equal to "recur"
2017-04-01 08:19:44 +03:00
Tuukka Turto
4a5e2fd852 Merge branch 'master' into walk-loop 2017-04-01 08:15:10 +03:00
Tuukka Turto
5b2d823028 Add --repl-output-fn into command line docs 2017-04-01 08:10:45 +03:00
Kodi Arfer
c51ec11fb6 Merge pull request #1264 from Kodiologist/repl-except-do-tests
Add tests for #533
2017-03-31 18:16:38 -07:00
Kodi Arfer
a7085138f6 Add tests for #533 2017-03-30 16:10:34 -07:00
Kodi Arfer
5aadeba3fe Fix bug: loop replaced strings equal to "recur" 2017-03-30 15:49:10 -07:00
Kodi Arfer
f8e5645c2e Small NEWS and docs fixes for hy-repr (#1258) 2017-03-25 12:13:44 -05:00
Kodi Arfer
741b9b9bd6 Merge branch 'hy-repr' 2017-03-25 08:22:38 -07:00
Kodi Arfer
e478008cce Fix HyMacroExpansionError underline alignment 2017-03-24 11:09:30 -07:00
Kodi Arfer
ca1bd0ffd3 Add a test for as-> in the REPL
Closes #1255.
2017-03-24 09:03:55 -07:00
Kodi Arfer
33a696d487 Add a command-line option --repl-output-fn (especially for hy.contrib.hy-repr) 2017-03-24 09:03:12 -07:00
Kodi Arfer
bf2f90a0d9 Add hy.contrib.hy-repr 2017-03-24 08:43:53 -07:00
Kodi Arfer
32e76caafe Refactor test_bin 2017-03-24 08:43:53 -07:00
Kodi Arfer
ae1dd78c53 Make setv always return None 2017-03-24 06:38:30 +02:00
Tuukka Turto
61f4277104 Merge branch 'kirbyfan64-yield-ret' 2017-03-19 22:27:06 +02:00
Tuukka Turto
2ee91f6dc6 Merge branch 'yield-ret'
Conflicts:
	NEWS
2017-03-19 22:26:13 +02:00
Kodi Arfer
504e56361b Merge pull request #1250 from pothos/master
fix example in documentation to unquote in quasi quote
2017-03-09 07:25:45 -08:00
Kodi Arfer
05cfe89dd9 Merge branch 'master' into master 2017-03-09 07:24:07 -08:00
Kodi Arfer
13170f8ee7 Merge pull request #1249 from john-patterson/patch-1
Added class use example to tutorial
2017-03-09 07:19:11 -08:00
Kai Lüke
35c872edb7 adhere to contributing guide by adding PR author 2017-03-09 16:07:21 +01:00
John Patterson
520b83d40b Updated AUTHORS file
As per CONTRIBUTING documentation, here is a seperate commit to add my entry to AUTHORS.rst.
2017-03-09 08:16:23 -06:00
Kai Lüke
80f0e4af14 fix example in documentation to unquote in quasi quote 2017-03-09 15:02:23 +01:00
John Patterson
8fb7706a68 Added class use example to tutorial
I was following along and noticed that it wasn't actually explained how to _use_ the object we just made. I include both the `setv` style of writing the Hy as we've been using in the rest of the docs up to this point and a more LISP-y style use of the object.
2017-03-08 22:39:41 -06:00
Ryan Gonzalez
7c82c01a6a Fix #151 (again!): yield inside with wasn't propagated to Result 2017-03-08 16:04:48 -06:00
Kodi Arfer
5f00921dea Fix #1243: read raises EOFError on false inputs (#1244)
* Fix #1243: `read` raises EOFError on false inputs

* Fix crash when trying to `eval` false values
2017-03-06 10:51:25 -06:00
Kodi Arfer
8b6a45e43a Remove car and cdr in favor of first and rest (#1241)
* Remove uses of `car` and `cdr` in /hy

* Remove uses of `car` and `cdr` in quote tests

* Remove `car` and `cdr` in favor of `first` and `rest`

I beefed up the documentation and tests for `first` and `rest` while I was at it.

I defined `car` and `cdr` in native_tests.cons so the tests read a bit more naturally.
2017-03-06 10:34:40 -06:00
Kodi Arfer
8ecb17d1fd Fix bug: quoting a bytestring raises ImportError (#1245) 2017-03-04 19:04:28 -06:00
Kodi Arfer
6620cc4e6f Merge pull request #1235 from Kodiologist/test-reorg
Minor test reorganization
2017-03-02 18:45:17 -08:00
Kodi Arfer
484daafa53 Move hy.core.reserved to hy.extra.reserved (#1231)
It was an odd one out by being in hy.core but needing to be called by a qualified name. It's at home in hy.extra.
2017-03-02 16:49:32 -06:00
Kodi Arfer
ebfa636b50 Fix #1237: iterator-handling bug in partition
Also, `partition` with n < 0 now raises an error.
2017-02-26 20:37:35 +02:00
Tuukka Turto
8b84114869 Document get in nested structure (#1236) 2017-02-24 14:22:27 -08:00
Kodi Arfer
d649147b0c Minor test reorganization
This removes two singleton directories.
2017-02-24 12:47:35 -08:00
Kodi Arfer
e4a7b317e1 Make fn work like lambda and remove lambda (#1228)
* with-decorator: Allow a `setv` form as the form to be decorated

This feature is of dubious value by itself, but it's necessary to allow `defn` to create a lambda instead of a `def`.

* Make `fn` work the same as `lambda`

That is, allow it to generate a `lambda` instead of a `def` statement if the function body is just an expression.

I've removed two uses of with_decorator in hy.compiler because they'd require adding another case to HyASTCompiler.compile_decorate_expression and they have no ultimate effect, anyway.

In a few tests, I've added a meaningless statement in `fn` bodies to force generation of a `def`.

I've removed `test_fn_compiler_empty_function` rather than rewrite it because it seems like a pain to maintain and not very useful.

* Remove `lambda`, now that `fn` does the same thing
2017-02-22 17:36:52 -06:00
Kodi Arfer
45b7a4ac9d Add bytestring literals 2017-02-19 09:04:45 +02:00
Kodi Arfer
92d5d6b42c Merge pull request #1224 from Kodiologist/refactor-models
Refactor hy.models
2017-02-17 07:42:40 -08:00
Kodi Arfer
0336ff3c68 Don't put redundant names in _stdlib (#1221)
This prevents pointless imports of hy.core, like importing `map` in Python 3.
2017-02-16 21:14:06 -07:00
Kodi Arfer
62e5d8e3e3 In hy.models, factor out strip_digit_separators 2017-02-16 19:43:16 -08:00