Skip to content

Commit

Permalink
Improve docs and Remove all-stable feature
Browse files Browse the repository at this point in the history
  • Loading branch information
kngwyu committed Jun 21, 2020
1 parent a63e426 commit 404f398
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 12 deletions.
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ rustversion = "1.0"
[features]
default = ["macros"]
macros = ["ctor", "indoc", "inventory", "paste", "pyo3cls", "unindent"]
# For CI
all-stable = ["default", "num-bigint", "num-complex"]
# Optimizes PyObject to Vec conversion and so on.
nightly = []

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fmt:

clippy:
@touch src/lib.rs # Touching file to ensure that cargo clippy will re-check the project
cargo clippy --features=all-stable --tests -- \
cargo clippy --features="default num-bigint num-complex" --tests -- \
$(addprefix -D ,${CLIPPY_LINTS_TO_DENY})
for example in examples/*; do (cd $$example/; cargo clippy) || exit 1; done

Expand Down
2 changes: 1 addition & 1 deletion ci/travis/guide.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ mdbook build -d ../target/guide guide

# Build the doc
# This builds the book in target/doc
cargo doc --features=all-stable --no-deps
cargo doc --features="default num-bigint num-complex" --no-deps
echo "<meta http-equiv=refresh content=0;url=pyo3/index.html>" > target/doc/index.html

# Get the lastest tag across all branches
Expand Down
8 changes: 4 additions & 4 deletions guide/src/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ extension-module = ["pyo3/extension-module"]
default = ["extension-module"]
```

## `nightly` flag
## The `nightly` feature

`pyo3/nightly` feature needs nightly compiler, but enables some optimizations as follows:
- `FromPyObject` for `Vec` and array is optimized when the object can be `PyBuffer`
- `ToBorrowedObject`, used by `PyDict::set_item` or so, is optimized when the taken object is a Python native type.
The `pyo3/nightly` feature needs the nightly Rust compiler. This allows PyO3 to use Rust's unstable specialization feature to apply the following optimizations:
- `FromPyObject` for `Vec` and `[T;N]` can perform a `memcpy` when the object is a `PyBuffer`
- `ToBorrowedObject` can skip a reference count increase when the provided object is a Python native type.
2 changes: 1 addition & 1 deletion guide/src/class.md
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ To enable this, we use a static registry type provided by [inventory](https://gi
which allows us to collect `impl`s from arbitrary source code by exploiting some binary trick.
See [inventory: how it works](https://github.com/dtolnay/inventory#how-it-works) and `pyo3_derive_backend::py_class` for more details.
Also for `#[pyproto]`, we use a similar, but more task-specific registry and
initialize it by [ctor](https://github.com/mmastrac/rust-ctor) crate.
initialize it using the [ctor](https://github.com/mmastrac/rust-ctor) crate.

Specifically, the following implementation is generated:

Expand Down
2 changes: 1 addition & 1 deletion guide/src/rust_cpython.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This chapter is based on the discussion in [PyO3/pyo3#55](https://github.com/PyO

## Macros

While rust-cpython has a macro based dsl for declaring modules and classes, PyO3 uses proc macros. PyO3 also doesn't change your struct and functions so you can still use them as normal Rust functions.
While rust-cpython has a `macro_rules!` based dsl for declaring modules and classes, PyO3 uses proc macros. PyO3 also doesn't change your struct and functions so you can still use them as normal Rust functions.

**rust-cpython**

Expand Down
1 change: 1 addition & 0 deletions guide/src/trait_bounds.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ Now we add the PyO3 annotations to the trait implementation:
impl Model for UserModel {
// the previous trait implementation
}
```

However, the previous code will not compile. The compilation error is the following one:
`error: #[pymethods] cannot be used on trait impl blocks`
Expand Down
4 changes: 2 additions & 2 deletions guide/src/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ references is done at runtime using `PyCell`, a scheme very similar to

## Object types

### [`PyAny`]
### [`PyAny`][PyAny]

**Represents:** a Python object of unspecified type, restricted to a GIL
lifetime. Currently, `PyAny` can only ever occur as a reference, `&PyAny`.
Expand Down Expand Up @@ -95,7 +95,7 @@ These types all implement `Deref<Target = PyAny>`, so they all expose the same
methods which can be found on `PyAny`.

To see all Python types exposed by `PyO3` you should consult the
[`pyo3::types`] module.
[`pyo3::types`][pyo3::types] module.

**Conversions:**

Expand Down

0 comments on commit 404f398

Please sign in to comment.