Skip to content

Commit 4026242

Browse files
committed
Use indexmap for returning dicts to Python
1 parent b61bd94 commit 4026242

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

Cargo.lock

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

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ bytes = "1.7.0"
1717
chrono = "0.4.38"
1818
futures = "0.3.31"
1919
http = "1.1"
20+
indexmap = "2"
2021
object_store = "0.11"
21-
pyo3 = { version = "0.22", features = ["macros"] }
22+
pyo3 = { version = "0.22", features = ["macros", "indexmap"] }
2223
pyo3-async-runtimes = { git = "https://github.com/PyO3/pyo3-async-runtimes", features = [
2324
"tokio-runtime",
2425
] }

object-store-rs/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ bytes = { workspace = true }
2222
chrono = { workspace = true }
2323
futures = { workspace = true }
2424
http = { workspace = true }
25+
indexmap = { workspace = true }
2526
object_store = { workspace = true }
2627
pyo3 = { workspace = true, features = ["chrono", "abi3-py39"] }
2728
pyo3-async-runtimes = { workspace = true, features = ["tokio-runtime"] }

object-store-rs/src/list.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use std::collections::HashMap;
21
use std::sync::Arc;
32

43
use futures::stream::BoxStream;
54
use futures::StreamExt;
5+
use indexmap::IndexMap;
66
use object_store::path::Path;
77
use object_store::{ListResult, ObjectMeta, ObjectStore};
88
use pyo3::prelude::*;
@@ -21,7 +21,7 @@ impl PyObjectMeta {
2121

2222
impl IntoPy<PyObject> for PyObjectMeta {
2323
fn into_py(self, py: Python<'_>) -> PyObject {
24-
let mut dict = HashMap::with_capacity(5);
24+
let mut dict = IndexMap::with_capacity(5);
2525
dict.insert("location", self.0.location.as_ref().into_py(py));
2626
dict.insert("last_modified", self.0.last_modified.into_py(py));
2727
dict.insert("size", self.0.size.into_py(py));
@@ -35,7 +35,7 @@ pub(crate) struct PyListResult(ListResult);
3535

3636
impl IntoPy<PyObject> for PyListResult {
3737
fn into_py(self, py: Python<'_>) -> PyObject {
38-
let mut dict = HashMap::with_capacity(2);
38+
let mut dict = IndexMap::with_capacity(2);
3939
dict.insert(
4040
"common_prefixes",
4141
self.0

object-store-rs/src/put.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use std::collections::HashMap;
21
use std::fs::File;
32
use std::io::{BufReader, Cursor, Read, Seek, SeekFrom};
43
use std::path::PathBuf;
54
use std::sync::Arc;
65

6+
use indexmap::IndexMap;
77
use object_store::path::Path;
88
use object_store::{ObjectStore, PutPayload, PutResult, WriteMultipart};
99
use pyo3::prelude::*;
@@ -80,7 +80,7 @@ pub(crate) struct PyPutResult(PutResult);
8080

8181
impl IntoPy<PyObject> for PyPutResult {
8282
fn into_py(self, py: Python<'_>) -> PyObject {
83-
let mut dict = HashMap::with_capacity(2);
83+
let mut dict = IndexMap::with_capacity(2);
8484
dict.insert("e_tag", self.0.e_tag.into_py(py));
8585
dict.insert("version", self.0.version.into_py(py));
8686
dict.into_py(py)

0 commit comments

Comments
 (0)