|
1 | 1 | mypyc: Mypy to Python C Extension Compiler |
2 | 2 | ========================================== |
3 | 3 |
|
4 | | -**NOTE: We are in the process of moving the mypyc README to the** |
5 | | -**[mypyc repository](https://github.com/mypyc/mypyc)** |
| 4 | +For the mypyc README, refer to the [mypyc repository](https://github.com/mypyc/mypyc). The mypyc |
| 5 | +repository also contains the mypyc issue tracker. All mypyc code lives |
| 6 | +here in the mypy repository. |
6 | 7 |
|
7 | | -**This may be out of date!** |
| 8 | +Source code for the mypyc user documentation lives under |
| 9 | +[mypyc/doc](./doc). |
8 | 10 |
|
9 | | -Mypyc is a compiler that compiles mypy-annotated, statically typed |
10 | | -Python modules into CPython C extensions. Currently our primary focus |
11 | | -is on making mypy faster through compilation -- the default mypy wheels |
12 | | -are compiled with mypyc. Compiled mypy is about 4x faster than |
13 | | -without compilation. |
14 | | - |
15 | | -Mypyc compiles what is essentially a Python language variant using "strict" |
16 | | -semantics. This means (among some other things): |
17 | | - |
18 | | - * Most type annotations are enforced at runtime (raising ``TypeError`` on mismatch) |
19 | | - |
20 | | - * Classes are compiled into extension classes without ``__dict__`` |
21 | | - (much, but not quite, like if they used ``__slots__``) |
22 | | - |
23 | | - * Monkey patching doesn't work |
24 | | - |
25 | | - * Instance attributes won't fall back to class attributes if undefined |
26 | | - |
27 | | - * Also there are still a bunch of bad bugs and unsupported features :) |
28 | | - |
29 | | -Compiled modules can import arbitrary Python modules, and compiled modules |
30 | | -can be used from other Python modules. Typically mypyc is used to only |
31 | | -compile modules that contain performance bottlenecks. |
32 | | - |
33 | | -You can run compiled modules also as normal, interpreted Python |
34 | | -modules, since mypyc targets valid Python code. This means that |
35 | | -all Python developer tools and debuggers can be used. |
36 | | - |
37 | | -macOS Requirements |
38 | | ------------------- |
39 | | - |
40 | | -* macOS Sierra or later |
41 | | - |
42 | | -* Xcode command line tools |
43 | | - |
44 | | -* Python 3.5+ from python.org (other versions are untested) |
45 | | - |
46 | | -Linux Requirements |
47 | | ------------------- |
48 | | - |
49 | | -* A recent enough C/C++ build environment |
50 | | - |
51 | | -* Python 3.5+ |
52 | | - |
53 | | -Windows Requirements |
54 | | --------------------- |
55 | | - |
56 | | -* Windows has been tested with Windows 10 and MSVC 2017. |
57 | | - |
58 | | -* Python 3.5+ |
59 | | - |
60 | | -Quick Start for Contributors |
61 | | ----------------------------- |
62 | | - |
63 | | -First clone the mypy git repository: |
64 | | - |
65 | | - $ git clone https://github.com/python/mypy.git |
66 | | - $ cd mypy |
67 | | - |
68 | | -Optionally create a virtualenv (recommended): |
69 | | - |
70 | | - $ python3 -m venv <directory> |
71 | | - $ source <directory>/bin/activate |
72 | | - |
73 | | -Then install the dependencies: |
74 | | - |
75 | | - $ python3 -m pip install -r test-requirements.txt |
76 | | - |
77 | | -Now you can run the tests: |
78 | | - |
79 | | - $ pytest -q mypyc |
80 | | - |
81 | | -Look at the [issue tracker](https://github.com/mypyc/mypyc/issues) |
82 | | -for things to work on. Please express your interest in working on an |
83 | | -issue by adding a comment before doing any significant work, since |
84 | | -there is a risk of duplicate work. |
85 | | - |
86 | | -Note that the issue tracker is hosted on the mypyc GitHub project, not |
87 | | -with mypy itself. |
88 | | - |
89 | | -Documentation |
90 | | -------------- |
91 | | - |
92 | | -We have some [developer documentation](doc/dev-intro.md). |
93 | | - |
94 | | -Development Status and Roadmap |
95 | | ------------------------------- |
96 | | - |
97 | | -These are the current planned major milestones: |
98 | | - |
99 | | -1. [DONE] Support a smallish but useful Python subset. Focus on compiling |
100 | | - single modules, while the rest of the program is interpreted and does not |
101 | | - need to be type checked. |
102 | | - |
103 | | -2. [DONE] Support compiling multiple modules as a single compilation unit (or |
104 | | - dynamic linking of compiled modules). Without this inter-module |
105 | | - calls will use slower Python-level objects, wrapper functions and |
106 | | - Python namespaces. |
107 | | - |
108 | | -3. [DONE] Mypyc can compile mypy. |
109 | | - |
110 | | -4. [DONE] Optimize some important performance bottlenecks. |
111 | | - |
112 | | -5. [PARTIALLY DONE] Generate useful errors for code that uses unsupported Python |
113 | | - features instead of crashing or generating bad code. |
114 | | - |
115 | | -6. [DONE] Release a version of mypy that includes a compiled mypy. |
116 | | - |
117 | | -7. |
118 | | - 1. More feature/compatibility work. (100% compatibility with Python is distinctly |
119 | | - an anti-goal, but more than we have now is a good idea.) |
120 | | - 2. [DONE] Support compiling Black, which is a prominent tool that could benefit |
121 | | - and has maintainer buy-in. |
122 | | - (Let us know if you maintain another Python tool or library and are |
123 | | - interested in working with us on this!) |
124 | | - 3. More optimization! Code size reductions in particular are likely to |
125 | | - be valuable and will speed up mypyc compilation. |
126 | | - |
127 | | -8. We'll see! Adventure is out there! |
128 | | - |
129 | | -Future |
130 | | ------- |
131 | | - |
132 | | -We have some ideas for |
133 | | -[future improvements and optimizations](doc/future.md). |
| 11 | +Mypyc welcomes new contributors! Refer to our |
| 12 | +[developer documentation](./doc/dev-intro.md) for more information. |
0 commit comments