Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions vm/src/builtins/range.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use super::{PyInt, PyIntRef, PySlice, PyTupleRef, PyType, PyTypeRef};
use crate::atomic_func;
use crate::common::hash::PyHash;
use super::{
builtins_iter, tuple::tuple_hash, PyInt, PyIntRef, PySlice, PyTupleRef, PyType, PyTypeRef,
};
use crate::{
builtins::builtins_iter,
atomic_func,
class::PyClassImpl,
common::hash::PyHash,
function::{FuncArgs, OptionalArg, PyComparisonValue},
protocol::{PyIterReturn, PyMappingMethods, PySequenceMethods},
types::{
Expand Down Expand Up @@ -442,7 +443,7 @@ impl Hashable for PyRange {
zelf.step().into(),
]
};
crate::utils::hash_iter(elements.iter(), vm)
tuple_hash(&elements, vm)
}
}

Expand Down
10 changes: 8 additions & 2 deletions vm/src/builtins/tuple.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use once_cell::sync::Lazy;

use super::{PositionIterInternal, PyGenericAlias, PyType, PyTypeRef};
use crate::atomic_func;
use crate::common::{hash::PyHash, lock::PyMutex};
use crate::{
atomic_func,
class::PyClassImpl,
convert::{ToPyObject, TransmuteFromObject},
function::{OptionalArg, PyArithmeticValue, PyComparisonValue},
Expand Down Expand Up @@ -372,7 +372,7 @@ impl AsSequence for PyTuple {
impl Hashable for PyTuple {
#[inline]
fn hash(zelf: &crate::Py<Self>, vm: &VirtualMachine) -> PyResult<PyHash> {
crate::utils::hash_iter(zelf.elements.iter(), vm)
tuple_hash(zelf.as_slice(), vm)
}
}

Expand Down Expand Up @@ -523,3 +523,9 @@ impl<T: TransmuteFromObject> ToPyObject for PyTupleTyped<T> {
self.tuple.into()
}
}

pub(super) fn tuple_hash(elements: &[PyObjectRef], vm: &VirtualMachine) -> PyResult<PyHash> {
// TODO: See #3460 for the correct implementation.
// https://github.com/RustPython/RustPython/pull/3460
crate::utils::hash_iter(elements.iter(), vm)
}