Skip to content

Commit

Permalink
Update mapping to return PyList instead of Sequence.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Matlock committed Oct 26, 2024
1 parent e9a33ae commit 86709aa
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/types/mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::py_result_ext::PyResultExt;
use crate::sync::GILOnceCell;
use crate::type_object::PyTypeInfo;
use crate::types::any::PyAnyMethods;
use crate::types::{PyAny, PyDict, PySequence, PyType};
use crate::types::{PyAny, PyDict, PyList, PyType};
use crate::{ffi, Py, PyTypeCheck, Python};

/// Represents a reference to a Python object supporting the mapping protocol.
Expand Down Expand Up @@ -77,14 +77,14 @@ pub trait PyMappingMethods<'py>: crate::sealed::Sealed {
where
K: IntoPyObject<'py>;

/// Returns a sequence containing all keys in the mapping.
fn keys(&self) -> PyResult<Bound<'py, PySequence>>;
/// Returns a list containing all keys in the mapping.
fn keys(&self) -> PyResult<Bound<'py, PyList>>;

/// Returns a sequence containing all values in the mapping.
fn values(&self) -> PyResult<Bound<'py, PySequence>>;
/// Returns a list containing all values in the mapping.
fn values(&self) -> PyResult<Bound<'py, PyList>>;

/// Returns a sequence of tuples of all (key, value) pairs in the mapping.
fn items(&self) -> PyResult<Bound<'py, PySequence>>;
/// Returns a list of all (key, value) pairs in the mapping.
fn items(&self) -> PyResult<Bound<'py, PyList>>;
}

impl<'py> PyMappingMethods<'py> for Bound<'py, PyMapping> {
Expand Down Expand Up @@ -133,7 +133,7 @@ impl<'py> PyMappingMethods<'py> for Bound<'py, PyMapping> {
}

#[inline]
fn keys(&self) -> PyResult<Bound<'py, PySequence>> {
fn keys(&self) -> PyResult<Bound<'py, PyList>> {
unsafe {
ffi::PyMapping_Keys(self.as_ptr())
.assume_owned_or_err(self.py())
Expand All @@ -142,7 +142,7 @@ impl<'py> PyMappingMethods<'py> for Bound<'py, PyMapping> {
}

#[inline]
fn values(&self) -> PyResult<Bound<'py, PySequence>> {
fn values(&self) -> PyResult<Bound<'py, PyList>> {
unsafe {
ffi::PyMapping_Values(self.as_ptr())
.assume_owned_or_err(self.py())
Expand All @@ -151,7 +151,7 @@ impl<'py> PyMappingMethods<'py> for Bound<'py, PyMapping> {
}

#[inline]
fn items(&self) -> PyResult<Bound<'py, PySequence>> {
fn items(&self) -> PyResult<Bound<'py, PyList>> {
unsafe {
ffi::PyMapping_Items(self.as_ptr())
.assume_owned_or_err(self.py())
Expand Down

0 comments on commit 86709aa

Please sign in to comment.