-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf82484
commit 24b77cd
Showing
7 changed files
with
181 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// TODO: remove this file once a new pyo3 version is released | ||
// with https://github.com/PyO3/pyo3/pull/2358 | ||
|
||
use pyo3::types::PySequence; | ||
use pyo3::{ffi, pyobject_native_type_core, PyAny, PyTryFrom}; | ||
|
||
/// Represents a Python `dict_keys`. | ||
#[cfg(not(PyPy))] | ||
#[repr(transparent)] | ||
pub struct PyDictKeys(PyAny); | ||
|
||
#[cfg(not(PyPy))] | ||
pyobject_native_type_core!( | ||
PyDictKeys, | ||
ffi::PyDictKeys_Type, | ||
#checkfunction=ffi::PyDictKeys_Check | ||
); | ||
|
||
impl PyDictKeys { | ||
pub fn as_sequence(&self) -> &PySequence { | ||
unsafe { PySequence::try_from_unchecked(self) } | ||
} | ||
} | ||
|
||
/// Represents a Python `dict_values`. | ||
#[cfg(not(PyPy))] | ||
#[repr(transparent)] | ||
pub struct PyDictValues(PyAny); | ||
|
||
#[cfg(not(PyPy))] | ||
pyobject_native_type_core!( | ||
PyDictValues, | ||
ffi::PyDictValues_Type, | ||
#checkfunction=ffi::PyDictValues_Check | ||
); | ||
|
||
impl PyDictValues { | ||
pub fn as_sequence(&self) -> &PySequence { | ||
unsafe { PySequence::try_from_unchecked(self) } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
use pyo3::prelude::*; | ||
|
||
#[cfg(not(PyPy))] | ||
mod _pyo3_dict; | ||
mod datetime; | ||
mod input_abstract; | ||
mod input_json; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters