Skip to content

Commit

Permalink
Merge pull request #683 from kngwyu/pyclass-new-layout
Browse files Browse the repository at this point in the history
New #[pyclass] system that is aware of its concrete layout
  • Loading branch information
kngwyu authored Jan 11, 2020
2 parents 95d045f + 439efbb commit fb17d5e
Show file tree
Hide file tree
Showing 71 changed files with 1,590 additions and 1,244 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,21 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

* The blanket implementations for `FromPyObject` for `&T` and `&mut T` are no longer specializable. Implement `PyTryFrom` for your type to control the behavior of `FromPyObject::extract()` for your types.
* The implementation for `IntoPy<U> for T` where `U: FromPy<T>` is no longer specializable. Control the behavior of this via the implementation of `FromPy`.
* `#[new]` does not take `PyRawObject` and can reutrn `Self` [#683](https://github.com/PyO3/pyo3/pull/683)

### Added

* Implemented `IntoIterator` for `PySet` and `PyFrozenSet`. [#716](https://github.com/PyO3/pyo3/pull/716)
* `PyClass`, `PyClassShell`, `PyObjectLayout`, `PyClassInitializer` [#683](https://github.com/PyO3/pyo3/pull/683)

### Fixed

* Clear error indicator when the exception is handled on the Rust side. [#719](https://github.com/PyO3/pyo3/pull/719)

### Removed

* `PyRef`, `PyRefMut`, `PyRawObject` [#683](https://github.com/PyO3/pyo3/pull/683)

## [0.8.5]

* Support for `#[name = "foo"]` attribute for `#[pyfunction]` and in `#[pymethods]`. [#692](https://github.com/PyO3/pyo3/pull/692)
Expand Down
4 changes: 2 additions & 2 deletions examples/rustapi_module/src/buf_and_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ struct BytesExtractor {}
#[pymethods]
impl BytesExtractor {
#[new]
pub fn __new__(obj: &PyRawObject) {
obj.init({ BytesExtractor {} });
pub fn __new__() -> Self {
BytesExtractor {}
}

pub fn from_bytes(&mut self, bytes: &PyBytes) -> PyResult<usize> {
Expand Down
4 changes: 2 additions & 2 deletions examples/rustapi_module/src/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ pub struct TzClass {}
#[pymethods]
impl TzClass {
#[new]
fn new(obj: &PyRawObject) {
obj.init(TzClass {})
fn new() -> Self {
TzClass {}
}

fn utcoffset<'p>(&self, py: Python<'p>, _dt: &PyDateTime) -> PyResult<&'p PyDelta> {
Expand Down
4 changes: 2 additions & 2 deletions examples/rustapi_module/src/dict_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ pub struct DictSize {
#[pymethods]
impl DictSize {
#[new]
fn new(obj: &PyRawObject, expected: u32) {
obj.init(DictSize { expected })
fn new(expected: u32) -> Self {
DictSize { expected }
}

fn iter_dict(&mut self, _py: Python<'_>, dict: &PyDict) -> PyResult<u32> {
Expand Down
6 changes: 3 additions & 3 deletions examples/rustapi_module/src/othermod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ pub struct ModClass {
#[pymethods]
impl ModClass {
#[new]
fn new(obj: &PyRawObject) {
obj.init(ModClass {
fn new() -> Self {
ModClass {
_somefield: String::from("contents"),
})
}
}

fn noop(&self, x: usize) -> usize {
Expand Down
4 changes: 2 additions & 2 deletions examples/rustapi_module/src/subclassing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ pub struct Subclassable {}
#[pymethods]
impl Subclassable {
#[new]
fn new(obj: &PyRawObject) {
obj.init(Subclassable {});
fn new() -> Self {
Subclassable {}
}
}

Expand Down
6 changes: 3 additions & 3 deletions examples/word-count/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ struct WordCounter {
#[pymethods]
impl WordCounter {
#[new]
fn new(obj: &PyRawObject, path: String) {
obj.init(WordCounter {
fn new(path: String) -> Self {
WordCounter {
path: PathBuf::from(path),
});
}
}

/// Searches for the word, parallelized by rayon
Expand Down
Loading

0 comments on commit fb17d5e

Please sign in to comment.