forked from python/mypy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge https://github.com/mypyc/mypyc into merge-mypyc
The mypyc history was rewritten before this merge to fix up PR and issue references to be cross-repo references. The command was `git filter-branch -f --msg-filter 'sed "s@\(^\|[ (]\)\(#[0-9]\+\)@\1mypyc/mypyc\2@g"'`
- Loading branch information
Showing
142 changed files
with
70,851 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash -eux | ||
|
||
# Build a debug build of python, install it, and create a venv for it | ||
# This is mainly intended for use in our travis builds but it can work | ||
# locally. (Though it unfortunately uses brew on OS X to deal with openssl | ||
# nonsense.) | ||
# Usage: build-debug-python.sh <version> <install prefix> <venv location> | ||
# | ||
# Running it locally might look something like: mkdir -p ~/tmp/cpython-debug && cd ~/tmp/cpython-debug && ~/src/mypy/misc/build-debug-python.sh 3.6.6 ~/tmp/cpython-debug ~/src/mypy/env-debug | ||
|
||
VERSION=$1 | ||
PREFIX=$2 | ||
VENV=$3 | ||
if [[ -f $PREFIX/bin/python3 ]]; then | ||
exit | ||
fi | ||
|
||
CPPFLAGS="" | ||
LDFLAGS="" | ||
if [[ $(uname) == Darwin ]]; then | ||
brew install openssl xz | ||
CPPFLAGS="-I$(brew --prefix openssl)/include" | ||
LDFLAGS="-L$(brew --prefix openssl)/lib" | ||
fi | ||
|
||
curl -O https://www.python.org/ftp/python/$VERSION/Python-$VERSION.tgz | ||
tar zxf Python-$VERSION.tgz | ||
cd Python-$VERSION | ||
CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" ./configure CFLAGS="-DPy_DEBUG -DPy_TRACE_REFS -DPYMALLOC_DEBUG" --with-pydebug --prefix=$PREFIX | ||
make -j4 | ||
make install | ||
$PREFIX/bin/python3 -m pip install virtualenv | ||
$PREFIX/bin/python3 -m virtualenv $VENV | ||
ln -s python3-config $PREFIX/bin/python-config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
echo "Cleaning C/C++ build artifacts..." | ||
(cd mypyc/lib-rt; make clean) | ||
(cd mypyc/external/googletest/make; make clean) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
mypyc: Mypy to Python C Extension Compiler | ||
========================================== | ||
|
||
*Mypyc is (mostly) not yet useful for general Python development.* | ||
|
||
Mypyc is a compiler that compiles mypy-annotated, statically typed | ||
Python modules into CPython C extensions. Currently our primary focus | ||
is on making mypy faster through compilation -- the default mypy wheels | ||
are compiled with mypyc. Compiled mypy is about 4x faster than | ||
without compilation. | ||
|
||
Mypyc compiles what is essentially a Python language variant using "strict" | ||
semantics. This means (among some other things): | ||
|
||
* Most type annotations are enforced at runtime (raising ``TypeError`` on mismatch) | ||
|
||
* Classes are compiled into extension classes without ``__dict__`` | ||
(much, but not quite, like if they used ``__slots__``) | ||
|
||
* Monkey patching doesn't work | ||
|
||
* Instance attributes won't fall back to class attributes if undefined | ||
|
||
* Metaclasses not supported | ||
|
||
* Also there are still a bunch of bad bugs and unsupported features :) | ||
|
||
Compiled modules can import arbitrary Python modules, and compiled modules | ||
can be used from other Python modules. Typically mypyc is used to only | ||
compile modules that contain performance bottlenecks. | ||
|
||
You can run compiled modules also as normal, interpreted Python | ||
modules, since mypyc targets valid Python code. This means that | ||
all Python developer tools and debuggers can be used. | ||
|
||
macOS Requirements | ||
------------------ | ||
|
||
* macOS Sierra or later | ||
|
||
* Xcode command line tools | ||
|
||
* Python 3.5+ from python.org (other versions are untested) | ||
|
||
Linux Requirements | ||
------------------ | ||
|
||
* A recent enough C/C++ build environment | ||
|
||
* Python 3.5+ | ||
|
||
Windows Requirements | ||
-------------------- | ||
|
||
* Windows has been tested with Windows 10 and MSVC 2017. | ||
|
||
* Python 3.5+ | ||
|
||
Quick Start for Contributors | ||
---------------------------- | ||
|
||
First clone the mypy git repository *and git submodules*: | ||
|
||
$ git clone --recurse-submodules https://github.com/mypyc/mypy.git | ||
$ cd mypy | ||
|
||
Optionally create a virtualenv (recommended): | ||
|
||
$ virtualenv -p python3 <directory> | ||
$ source <directory>/bin/activate | ||
|
||
Then install the dependencies: | ||
|
||
$ python3 -m pip install -r test-requirements.txt | ||
|
||
Now you can run the tests: | ||
|
||
$ pytest mypyc | ||
|
||
Look at the [issue tracker](https://github.com/mypyc/mypyc/issues) | ||
for things to work on. Please express your interest in working on an | ||
issue by adding a comment before doing any significant work, since | ||
development is currently very active and there is real risk of duplicate | ||
work. | ||
|
||
Note that the issue tracker is still hosted on the mypyc project, not | ||
with mypy itself. | ||
|
||
Documentation | ||
------------- | ||
|
||
We have some [developer documentation](doc/dev-intro.md). | ||
|
||
Development Status and Roadmap | ||
------------------------------ | ||
|
||
These are the current planned major milestones: | ||
|
||
1. [DONE] Support a smallish but useful Python subset. Focus on compiling | ||
single modules, while the rest of the program is interpreted and does not | ||
need to be type checked. | ||
|
||
2. [DONE] Support compiling multiple modules as a single compilation unit (or | ||
dynamic linking of compiled modules). Without this inter-module | ||
calls will use slower Python-level objects, wrapper functions and | ||
Python namespaces. | ||
|
||
3. [DONE] Mypyc can compile mypy. | ||
|
||
4. [DONE] Optimize some important performance bottlenecks. | ||
|
||
5. [PARTIALLY DONE] Generate useful errors for code that uses unsupported Python | ||
features instead of crashing or generating bad code. | ||
|
||
6. [DONE] Release a version of mypy that includes a compiled mypy. | ||
|
||
7a. More feature/compatibility work. (100% compatibility with Python is distinctly | ||
an anti-goal, but more than we have now is a good idea.) | ||
|
||
7b. Support compiling Black, which is a prominent tool that could benefit | ||
and has maintainer buy-in. | ||
(Let us know if you maintain another Python tool or library and are | ||
interested in working with us on this!) | ||
|
||
7c. More optimization! Code size reductions in particular are likely to | ||
be valuable and will speed up mypyc compilation. | ||
|
||
8. We'll see! Adventure is out there! | ||
|
||
Future | ||
------ | ||
|
||
We have some ideas for | ||
[future improvements and optimizations](doc/future.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
Oops, something went wrong.