Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New #[pyclass] system that is aware of its concrete layout #683

Merged
merged 27 commits into from
Jan 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4b5fa7e
Introduce PyClass trait and PyClassShell
kngwyu Dec 7, 2019
bdb66af
Make PyClassShell have dict&weakref
kngwyu Dec 8, 2019
4d7dfaf
Allow slf: &PyClassShell<Self>
kngwyu Dec 8, 2019
a663907
Introduce PyInternalCaster
kngwyu Dec 14, 2019
b86de93
Introduce PyClassInitializer
kngwyu Dec 15, 2019
8175d6f
Merge branch 'master' into pyclass-new-layout
kngwyu Dec 19, 2019
6b84401
Make it enable to safely inherit native types
kngwyu Dec 21, 2019
efa16a6
Fix documents accompanied by PyClassShell
kngwyu Dec 22, 2019
e2dc843
Fix a corner case for PyClassInitializer
kngwyu Dec 22, 2019
acb1120
Fix examples with the new #[new] API
kngwyu Dec 22, 2019
d5cff05
Fix documents and a clippy warning
kngwyu Dec 22, 2019
ea51756
Resolve some clippy complains
kngwyu Dec 23, 2019
2e3ece8
Try to enhance class section in the guide
kngwyu Dec 23, 2019
5859039
Fix accidently changed file permission
kngwyu Dec 24, 2019
766a520
Documentation enhancement
kngwyu Dec 28, 2019
8f8785d
Merge branch 'master' into pyclass-new-layout
kngwyu Dec 29, 2019
18e565f
New PyClassInitializer
kngwyu Jan 5, 2020
60edeb8
Simplify IntoInitializer
davidhewitt Jan 6, 2020
b04d0af
Merge pull request #1 from davidhewitt/pyclass-new-layout
kngwyu Jan 7, 2020
b602b4b
Enhance documentation and tests around #[new]
kngwyu Jan 7, 2020
f26e07c
Replace IntoInitializer<T> with Into<PyClassInitializer<T>>
kngwyu Jan 7, 2020
67a98d6
Remove unnecessary Box
kngwyu Jan 7, 2020
ab0a731
Fix use order in prelude
kngwyu Jan 7, 2020
451de18
Merge branch 'master' into pyclass-new-layout
kngwyu Jan 8, 2020
c57177a
Refine tests and documents around pyclass.rs
kngwyu Jan 8, 2020
302b3bb
Merge branch 'master' into pyclass-new-layout
kngwyu Jan 11, 2020
439efbb
Update CHANGELOG
kngwyu Jan 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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