dbf7b233aa
3203: support ordering magic methods for `#[pyclass]` r=adamreichold a=davidhewitt Closes #2089 This adds `__lt__`, `__le__`, `__eq__`, `__ne__`, `__gt__`, and `__ge__` as per the Python implementations of what we call `__richcmp__`. There's a UI test confirming that the user cannot implement split forms and `__richcmp__` simultaneously. There's also a benchmark comparing implementing these split methods against using `__richcmp__`. I couldn't see a meaningful performance difference, so I'm tempted to deprecate `__richcmp__`, given that's not a magic method which exists in Python. Potentially we can provide options such as the opt-in `#[pyclass(eq, ord)]` to avoid boilerplate for people who don't want to implement six different methods. Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com> |
||
---|---|---|
.. | ||
pyo3_pytests | ||
src | ||
tests | ||
build.rs | ||
Cargo.toml | ||
MANIFEST.in | ||
noxfile.py | ||
pyproject.toml | ||
README.md | ||
requirements-dev.txt |
pyo3-pytests
An extension module built using PyO3, used to test and benchmark PyO3 from Python.
Testing
This package is intended to be built using maturin
. Once built, you can run the tests using pytest
:
pip install maturin
maturin develop
pytest
Alternatively, install nox and run the tests inside an isolated environment:
nox
Running benchmarks
You can install the module in your Python environment and then run the benchmarks with pytest:
pip install .
pytest --benchmark-enable
Or with nox:
nox -s bench