Skip to content

Commit 2c8d76e

Browse files
authored
[mypyc] Add some user documentation (#8677)
This should cover most of the basics.
1 parent 125728a commit 2c8d76e

21 files changed

+1935
-0
lines changed

mypyc/doc/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

mypyc/doc/bool_operations.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
.. _bool-ops:
2+
3+
Native boolean operations
4+
=========================
5+
6+
Operations on ``bool`` values that are listed here have fast,
7+
optimized implementations.
8+
9+
Construction
10+
------------
11+
12+
* ``True``
13+
* ``False``
14+
* ``bool(obj)``
15+
16+
Operators
17+
---------
18+
19+
* ``b1 and b2``
20+
* ``b1 or b2``
21+
* ``not b``
22+
23+
Functions
24+
---------
25+
26+
* ``any(expr for ... in ...)``
27+
* ``all(expr for ... in ...)``

mypyc/doc/compilation_units.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.. _compilation-units:
2+
3+
Compilation units
4+
=================
5+
6+
When you run mypyc to compile a set of modules, these modules form a
7+
*compilation unit*. Mypyc will use early binding for references within
8+
the compilation unit.
9+
10+
If you run mypyc multiple times to compile multiple sets of modules,
11+
each invocation will result in a new compilation unit. References
12+
between separate compilation units will fall back to late binding,
13+
i.e. looking up names using Python namespace dictionaries. Also, all
14+
calls will use the slower Python calling convention, where arguments
15+
and the return value will be boxed (and potentially unboxed again in
16+
the called function).
17+
18+
For maximal performance, minimize interactions across compilation
19+
units. The simplest way to achieve this is to compile your entire
20+
program as a single compilation unit.

mypyc/doc/conf.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
7+
# -- Path setup --------------------------------------------------------------
8+
9+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
13+
# import os
14+
# import sys
15+
# sys.path.insert(0, os.path.abspath('.'))
16+
17+
18+
# -- Project information -----------------------------------------------------
19+
20+
project = 'mypyc'
21+
copyright = '2020, mypyc team'
22+
author = 'mypyc team'
23+
24+
25+
# -- General configuration ---------------------------------------------------
26+
27+
# Add any Sphinx extension module names here, as strings. They can be
28+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
29+
# ones.
30+
extensions = [
31+
]
32+
33+
# Add any paths that contain templates here, relative to this directory.
34+
templates_path = ['_templates']
35+
36+
# List of patterns, relative to source directory, that match files and
37+
# directories to ignore when looking for source files.
38+
# This pattern also affects html_static_path and html_extra_path.
39+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
40+
41+
42+
# -- Options for HTML output -------------------------------------------------
43+
44+
# The theme to use for HTML and HTML Help pages. See the documentation for
45+
# a list of builtin themes.
46+
#
47+
html_theme = 'alabaster'
48+
49+
# Add any paths that contain custom static files (such as style sheets) here,
50+
# relative to this directory. They are copied after the builtin static files,
51+
# so a file named "default.css" will overwrite the builtin "default.css".
52+
html_static_path = ['_static']

mypyc/doc/dict_operations.rst

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
.. _dict-ops:
2+
3+
Native dict operations
4+
======================
5+
6+
These ``dict`` operations have fast, optimized implementations. Other
7+
dictionary operations use generic implementations that are often slower.
8+
9+
Construction
10+
------------
11+
12+
Construct dict from keys and values:
13+
14+
* ``{key: value, ...}``
15+
16+
Construct dict from another object:
17+
18+
* ``dict(d: dict)``
19+
* ``dict(x: Iterable)``
20+
21+
Dict comprehensions:
22+
23+
* ``{...: ... for ... in ...}``
24+
* ``{...: ... for ... in ... if ...}``
25+
26+
Operators
27+
---------
28+
29+
* ``d[key]``
30+
* ``value in d``
31+
32+
Statements
33+
----------
34+
35+
* ``d[key] = value``
36+
37+
Methods
38+
-------
39+
40+
* ``d.get(key)``
41+
* ``d.get(key, default)``
42+
* ``d1.update(d2: dict)``
43+
* ``d.update(x: Iterable)``
44+
45+
Functions
46+
---------
47+
48+
* ``len(d: dict)``

0 commit comments

Comments
 (0)