Skip to content

Commit d38dc27

Browse files
authored
Bump pyo3-object_store to 0.1.0 (developmentseed#365)
1 parent d476a65 commit d38dc27

File tree

5 files changed

+51
-21
lines changed

5 files changed

+51
-21
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The simplest, highest-throughput [^1] Python interface to [S3][s3], [GCS][gcs],
2828
- Optionally return list results in [Apache Arrow](https://arrow.apache.org/) format, which is faster and more memory-efficient than materializing Python `dict`s.
2929
- Zero-copy data exchange between Rust and Python via the [buffer protocol](https://jakevdp.github.io/blog/2014/05/05/introduction-to-the-python-buffer-protocol/).
3030

31-
<!-- For Rust developers looking to add object_store support to their Python packages, refer to pyo3-object_store. -->
31+
For Rust developers looking to add `object_store` support to their own Python packages, refer to [`pyo3-object_store`](https://docs.rs/pyo3-object_store/latest/pyo3_object_store/).
3232

3333
[^1]: Benchmarking is ongoing, but preliminary results indicate roughly [9x higher throughput than fsspec](https://github.com/geospatial-jeff/pyasyncio-benchmark/blob/fe8f290cb3282dcc3bc96cae06ed5f90ad326eff/test_results/cog_header_results.csv) and [2.8x higher throughput than aioboto3](https://github.com/geospatial-jeff/pyasyncio-benchmark/blob/40e67509a248c5102a6b1608bcb9773295691213/test_results/20250218_results/ec2_m5/aggregated_results.csv) for many concurrent, small, get requests from an async context.
3434

pyo3-object_store/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
## [0.1.0] - 2025-03-14
4+
5+
- Initial release.

pyo3-object_store/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pyo3-object_store"
3-
version = "0.1.0-beta.4"
3+
version = "0.1.0"
44
authors = ["Kyle Barron <[email protected]>"]
55
edition = "2021"
66
description = "object_store integration for pyo3."

pyo3-object_store/README.md

+43-18
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,62 @@
22

33
Integration between [`object_store`](https://docs.rs/object_store) and [`pyo3`](https://github.com/PyO3/pyo3).
44

5-
This provides Python builder classes so that Python users can easily create `Arc<dyn ObjectStore>` instances, which can then be used in pure-Rust code.
5+
This provides Python builder classes so that Python users can easily create [`Arc<dyn ObjectStore>`][object_store::ObjectStore] instances, which can then be used in pure-Rust code.
66

77
## Usage
88

99
1. Register the builders.
1010

11-
```rs
12-
#[pymodule]
13-
fn python_module(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
14-
pyo3_object_store::register_store_module(py, m, "python_module")?;
15-
pyo3_object_store::register_exceptions_module(py, m, "python_module")?;
16-
}
17-
```
11+
```rs
12+
#[pymodule]
13+
fn python_module(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
14+
pyo3_object_store::register_store_module(py, m, "python_module", "store")?;
15+
pyo3_object_store::register_exceptions_module(py, m, "python_module", "exceptions")?;
16+
}
17+
```
1818

19-
This exports the underlying Python classes from your own Rust-Python library.
19+
This exports the underlying Python classes from your own Rust-Python library.
2020

21-
2. Accept `PyObjectStore` as a parameter in your function exported to Python. Its `into_inner` method gives you an `Arc<dyn ObjectStore>`.
21+
Refer to [`register_store_module`] and [`register_exceptions_module`] for more information.
2222

23-
```rs
24-
#[pyfunction]
25-
pub fn use_object_store(store: PyObjectStore) {
26-
let store: Arc<dyn ObjectStore> = store.into_inner();
27-
}
28-
```
23+
2. Accept [`PyObjectStore`] as a parameter in your function exported to Python. Its [`into_dyn`][PyObjectStore::into_dyn] method (or `Into` impl) gives you an [`Arc<dyn ObjectStore>`][object_store::ObjectStore].
24+
25+
```rs
26+
#[pyfunction]
27+
pub fn use_object_store(store: PyObjectStore) {
28+
let store: Arc<dyn ObjectStore> = store.into_dyn();
29+
}
30+
```
31+
32+
You can also accept [`AnyObjectStore`] as a parameter, which wraps [`PyObjectStore`] and [`PyExternalObjectStore`]. This allows you to seamlessly recreate `ObjectStore` instances that users pass in from other Python libraries (like [`obstore`][obstore]) that themselves export `pyo3-object_store` builders.
33+
34+
Note however that due to lack of [ABI stability](#abi-stability), `ObjectStore` instances will be **recreated**, and so there will be no connection pooling across the external store.
2935

3036
## Example
3137

32-
The `obstore` Python library gives a full real-world example of using `pyo3-object_store`. It
38+
The [`obstore`][obstore] Python library gives a full real-world example of using `pyo3-object_store`, exporting a Python API that mimics the Rust [`ObjectStore`][object_store::ObjectStore] API.
39+
40+
[obstore]: https://developmentseed.org/obstore/latest/
3341

3442
## ABI stability
3543

44+
It's [not currently possible](https://github.com/PyO3/pyo3/issues/1444) to share a `#[pyclass]` across multiple Python libraries, except in special cases where the underlying data has a stable ABI.
45+
46+
As `object_store` does not currently have a stable ABI, we can't share `PyObjectStore` instances across multiple separately-compiled Python libraries.
47+
48+
We have two ways to get around this:
49+
50+
- Export your own Python classes so that users can construct `ObjectStore` instances that were compiled _with your library_. See [`register_store_module`].
51+
- Accept [`AnyObjectStore`] or [`PyExternalObjectStore`] as a parameter, which allows for seamlessly **reconstructing** stores from an external Python library, like [`obstore`][obstore]. This has some overhead and removes any possibility of connection pooling across the two instances.
52+
3653
Note about not being able to use these across Python packages. It has to be used with the exported classes from your own library.
3754

38-
## Type hints
55+
## Python Type hints
56+
57+
We don't yet have a _great_ solution here for reusing the store builder type hints in your own library. Type hints are shipped with the cargo dependency. Or, you can use a submodule on the `obstore` repo. See [`async-tiff` for an example](https://github.com/developmentseed/async-tiff/blob/35eaf116d9b1ab31232a1e23298b3102d2879e9c/python/python/async_tiff/store).
58+
59+
## Version compatibility
60+
61+
| pyo3-object_store | pyo3 | object_store |
62+
| ----------------- | ---- | ------------ |
63+
| 0.1.x | 0.23 | 0.12 |

0 commit comments

Comments
 (0)