This is a compromise solution: we require the GIL to be held when acquiring
the slice, but not later when using the slice.
We could bind the lifetime of the returned slice to the Python-token lifetime
to prevent accessing the slice when the GIL is not held, but that causes
problems with the FromPyObject impl.
Alternatively we could not require the GIL at all when accessing the PyTuple
(and thus keep the ops::Index and IntoIterator implementations), but that
relies on too many CPython implementation details for my taste.
Warning: to use rust-cpython with --feature nightly, you now must use 'rustc 1.13.0-nightly (e9bc1bac8 2016-08-24)' or newer; or you'll get segfaults due to the drop flags.
Use of rust-cpython with stable rust is not affected.
* FromPyObject for all conversions that don't need to borrow temporaries
* RefFromPyObject for extracting references out of temporaries
(currently only used for extracting `&str`)
`<str as ToPyObject>::ObjectType` now always is `PyString`
(previously the type differed between Python 2.7 and 3.x)
`PyStringData` allows zero-copy access to Python's underlying string
representation.
Since the `Python` token no longer is a part of `PyObject`,
lots of methods now require the token as additional argument.
This [breaking-change] breaks everything!
This makes it possible iterate through a PyDict in Rust without
having to unpack tuples.
The PyList version of the method is renamed to `items_list()`.
[breaking-change]
Allows simplifying the common
`PyErr::new_lazy_init(py.get_type::<exc::ValueError>(), Some(msg.to_py_object(py).into_object()));`
to
`PyErr:🆕:<exc::ValueError, _>(py, msg)`
[breaking-change]
This is a [breaking-change] and makes the trait more difficult to implement.
The usage through PyObject::extract() is unchanged.
This change allows extracting a `&str` through a temporary `Cow<str>`
without having to copy the string data from python to rust
(at least in cases where the python string is UTF-8 encoded).
This is preparation in hope I'll be able to make py_fn!()
automatically extract the function arguments.