Skip to content

Commit

Permalink
Fix typos and other minor touchups to guide
Browse files Browse the repository at this point in the history
* Fix some typos
* Capitalize Rust, acronyms
* Remove some trailing whitespace
  • Loading branch information
thanatos authored and Vlad-Shcherbina committed Mar 15, 2018
1 parent 5dc5c53 commit 24eee46
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
12 changes: 6 additions & 6 deletions guide/src/class.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ impl MyClass {
}
```

From python prespective `method2`, in above example, does not accept any arguments.
From python perspective `method2`, in above example, does not accept any arguments.

## Class methods

Expand Down Expand Up @@ -341,7 +341,7 @@ Each parameter could one of following type:
corresponds to python's `def meth(*, arg1.., arg2=..)`
* args="\*": "args" is var args, corresponds to python's `def meth(*args)`. Type of `args`
parameter has to be `&PyTuple`.
* kwargs="\*\*": "kwargs" is kwyword arguments, corresponds to python's `def meth(**kwargs)`.
* kwargs="\*\*": "kwargs" is keyword arguments, corresponds to python's `def meth(**kwargs)`.
Type of `kwargs` parameter has to be `Option<&PyDict>`.
* arg="Value": arguments with default value. corresponds to python's `def meth(arg=Value)`.
if `arg` argument is defined after var arguments it is treated as keyword argument.
Expand All @@ -353,10 +353,10 @@ Example:
#[py::methods]
impl MyClass {

#[args(arg1=true, args="*", arg2=10, kwargs="**")]
fn method(&self, arg1: bool, args: &PyTuple, arg2: i32, kwargs: Option<&PyTuple>) -> PyResult<i32> {
#[args(arg1=true, args="*", arg2=10, kwargs="**")]
fn method(&self, arg1: bool, args: &PyTuple, arg2: i32, kwargs: Option<&PyTuple>) -> PyResult<i32> {
Ok(1)
}
}
}
```

Expand All @@ -381,7 +381,7 @@ To customize object attribute access define following methods:
* `fn __setattr__(&mut self, name: FromPyObject, value: FromPyObject) -> PyResult<()>`
* `fn __delattr__(&mut self, name: FromPyObject) -> PyResult<()>`

Each methods coresponds to python's `self.attr`, `self.attr = value` and `del self.attr` code.
Each methods corresponds to python's `self.attr`, `self.attr = value` and `del self.attr` code.

#### String Conversions

Expand Down
2 changes: 1 addition & 1 deletion guide/src/conversions.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn main() {
[`IntoPyDictPointer`][IntoPyDictPointer] trait. `HashMap` or `BTreeMap` could be used as
keyword arguments. rust tuple with up to 10 elements where each element is tuple with size 2
could be used as kwargs as well. Or `NoArgs` object can be used to indicate that
no keywords areguments are provided.
no keywords arguments are provided.

```rust,ignore
extern crate pyo3;
Expand Down
2 changes: 1 addition & 1 deletion guide/src/distribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ hello_rust-1.0-cp27-cp27mu-linux_x86_64.whl hello_rust-1.0-cp36-cp36m-linux
hello_rust-1.0-cp27-cp27mu-manylinux1_x86_64.whl hello_rust-1.0-cp36-cp36m-manylinux1_x86_64.whl
```

The `*-manylinux1_x86_64.whl` files are the `manylinux1` wheels that you can upload to PyPi.
The `*-manylinux1_x86_64.whl` files are the `manylinux1` wheels that you can upload to PyPI.

[setuptools-rust]: https://github.com/PyO3/setuptools-rust
6 changes: 3 additions & 3 deletions guide/src/exception.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Define a new exception

You can use the `py_exception!` macro to define a new excetpion type:
You can use the `py_exception!` macro to define a new exception type:

```rust
py_exception!(module, MyError);
Expand Down Expand Up @@ -93,7 +93,7 @@ fn main() {
}
```

[`Python::is_instance()`](https://pyo3.github.io/pyo3/pyo3/struct.Python.html#method.is_instance) calls the underlaying [`PyType::is_instance`](https://pyo3.github.io/pyo3/pyo3/struct.PyType.html#method.is_instance) method to do the actual work.
[`Python::is_instance()`](https://pyo3.github.io/pyo3/pyo3/struct.Python.html#method.is_instance) calls the underlying [`PyType::is_instance`](https://pyo3.github.io/pyo3/pyo3/struct.PyType.html#method.is_instance) method to do the actual work.

To check the type of an exception, you can simply do:

Expand All @@ -110,7 +110,7 @@ A [`PyErr`](https://pyo3.github.io/pyo3/pyo3/struct.PyErr.html) represents a Pyt
Errors within the `PyO3` library are also exposed as Python exceptions.

PyO3 library handles python exception in two stages. During first stage `PyErr` instance get
created. At this stage python gil is not required. During second stage, actual python
created. At this stage python GIL is not required. During second stage, actual python
exception instance get crated and set to python interpreter.

In simple case, for custom errors support implementation of `std::convert::From<T>` trait
Expand Down
18 changes: 9 additions & 9 deletions guide/src/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fn init_mod(py: Python, m: &PyModule) -> PyResult<()> {
Ok(())
}

// logic implemented as a normal rust function
// logic implemented as a normal Rust function
fn sum_as_string(a:i64, b:i64) -> String {
format!("{}", a + b).to_string()
}
Expand Down Expand Up @@ -125,19 +125,19 @@ You obtain a [`Python`](https://pyo3.github.io/pyo3/pyo3/struct.Python.html) ins
by acquiring the GIL, and have to pass it into some operations that call into the Python runtime.

PyO3 library provides wrappers for python native objects. Ownership of python objects are
disallowed because any access to python runtime has to be protected by GIL.
All apis are available through references. Lifetimes of python object's references are
disallowed because any access to python runtime has to be protected by GIL.
All APIs are available through references. Lifetimes of python object's references are
bound to GIL lifetime.

There are two types of pointers that could be stored on rust structs.
There are two types of pointers that could be stored on Rust structs.
Both implements `Send` and `Sync` traits and maintain python object's reference count.

* [`PyObject`](https://pyo3.github.io/pyo3/pyo3/struct.PyObject.html) is general purpose
type. It does not maintain type of the referenced object. It provides helper methods
for extracing rust values and casting to specific python object type.
* [`Py<T>`](https://pyo3.github.io/pyo3/pyo3/struct.Py.html) represents a reference to a
concrete python object `T`.
type. It does not maintain type of the referenced object. It provides helper methods
for extracting Rust values and casting to specific python object type.

* [`Py<T>`](https://pyo3.github.io/pyo3/pyo3/struct.Py.html) represents a reference to a
concrete python object `T`.

To upgrade to a reference [`AsPyRef`](https://pyo3.github.io/pyo3/pyo3/trait.AsPyRef.html)
trait can be used.

0 comments on commit 24eee46

Please sign in to comment.