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
3 changes: 0 additions & 3 deletions crates/stdlib/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,6 @@ mod array {
}
}

#[pymethod]
fn __getitem__(&self, needle: PyObjectRef, vm: &VirtualMachine) -> PyResult {
self.getitem_inner(&needle, vm)
}
Expand Down Expand Up @@ -1038,7 +1037,6 @@ mod array {
}
}

#[pymethod]
fn __setitem__(
zelf: &Py<Self>,
needle: PyObjectRef,
Expand All @@ -1055,7 +1053,6 @@ mod array {
}
}

#[pymethod]
fn __delitem__(&self, needle: PyObjectRef, vm: &VirtualMachine) -> PyResult<()> {
self.delitem_inner(&needle, vm)
}
Expand Down
1 change: 0 additions & 1 deletion crates/stdlib/src/contextvars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ mod _contextvars {
}
}

#[pymethod]
fn __getitem__(
&self,
var: PyRef<ContextVar>,
Expand Down
2 changes: 0 additions & 2 deletions crates/stdlib/src/mmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1240,12 +1240,10 @@ mod mmap {
Ok(())
}

#[pymethod]
fn __getitem__(&self, needle: PyObjectRef, vm: &VirtualMachine) -> PyResult<PyObjectRef> {
self.getitem_inner(&needle, vm)
}

#[pymethod]
fn __setitem__(
zelf: &Py<Self>,
needle: PyObjectRef,
Expand Down
3 changes: 0 additions & 3 deletions crates/vm/src/builtins/bytearray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,10 @@ impl PyByteArray {
Ok(zelf)
}

#[pymethod]
fn __getitem__(&self, needle: PyObjectRef, vm: &VirtualMachine) -> PyResult {
self._getitem(&needle, vm)
}

#[pymethod]
pub fn __delitem__(&self, needle: PyObjectRef, vm: &VirtualMachine) -> PyResult<()> {
self._delitem(&needle, vm)
}
Expand Down Expand Up @@ -549,7 +547,6 @@ impl PyByteArray {

#[pyclass]
impl Py<PyByteArray> {
#[pymethod]
fn __setitem__(
&self,
needle: PyObjectRef,
Expand Down
1 change: 0 additions & 1 deletion crates/vm/src/builtins/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ impl PyBytes {
PyBytesInner::maketrans(from, to, vm)
}

#[pymethod]
fn __getitem__(&self, needle: PyObjectRef, vm: &VirtualMachine) -> PyResult {
self._getitem(&needle, vm)
}
Expand Down
3 changes: 0 additions & 3 deletions crates/vm/src/builtins/dict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ impl PyDict {
self.entries.contains(vm, &*key)
}

#[pymethod]
fn __delitem__(&self, key: PyObjectRef, vm: &VirtualMachine) -> PyResult<()> {
self.inner_delitem(&*key, vm)
}
Expand All @@ -235,7 +234,6 @@ impl PyDict {
self.entries.clear()
}

#[pymethod]
fn __setitem__(
&self,
key: PyObjectRef,
Expand Down Expand Up @@ -372,7 +370,6 @@ impl Py<PyDict> {
Ok(Implemented(true))
}

#[pymethod]
#[cfg_attr(feature = "flame-it", flame("PyDictRef"))]
fn __getitem__(&self, key: PyObjectRef, vm: &VirtualMachine) -> PyResult {
self.inner_getitem(&*key, vm)
Expand Down
1 change: 0 additions & 1 deletion crates/vm/src/builtins/genericalias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ impl PyGenericAlias {
}
}

#[pymethod]
fn __getitem__(zelf: PyRef<Self>, needle: PyObjectRef, vm: &VirtualMachine) -> PyResult {
let new_args = subs_parameters(
zelf.to_owned().into(),
Expand Down
3 changes: 0 additions & 3 deletions crates/vm/src/builtins/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ impl PyList {
}
}

#[pymethod]
fn __getitem__(&self, needle: PyObjectRef, vm: &VirtualMachine) -> PyResult {
self._getitem(&needle, vm)
}
Expand All @@ -228,7 +227,6 @@ impl PyList {
}
}

#[pymethod]
fn __setitem__(
&self,
needle: PyObjectRef,
Expand Down Expand Up @@ -308,7 +306,6 @@ impl PyList {
}
}

#[pymethod]
fn __delitem__(&self, subscript: PyObjectRef, vm: &VirtualMachine) -> PyResult<()> {
self._delitem(&subscript, vm)
}
Expand Down
1 change: 0 additions & 1 deletion crates/vm/src/builtins/mappingproxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ impl PyMappingProxy {
)?))
}

#[pymethod]
pub fn __getitem__(&self, key: PyObjectRef, vm: &VirtualMachine) -> PyResult {
self.get_inner(key.clone(), vm)?
.ok_or_else(|| vm.new_key_error(key))
Expand Down
3 changes: 0 additions & 3 deletions crates/vm/src/builtins/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,6 @@ impl PyMemoryView {
self.release();
}

#[pymethod]
fn __getitem__(zelf: PyRef<Self>, needle: PyObjectRef, vm: &VirtualMachine) -> PyResult {
zelf.try_not_released(vm)?;
if zelf.desc.ndim() == 0 {
Expand All @@ -682,7 +681,6 @@ impl PyMemoryView {
}
}

#[pymethod]
fn __delitem__(&self, _needle: PyObjectRef, vm: &VirtualMachine) -> PyResult<()> {
if self.desc.readonly {
return Err(vm.new_type_error("cannot modify read-only memory"));
Expand Down Expand Up @@ -847,7 +845,6 @@ impl PyMemoryView {

#[pyclass]
impl Py<PyMemoryView> {
#[pymethod]
fn __setitem__(
&self,
needle: PyObjectRef,
Expand Down
1 change: 0 additions & 1 deletion crates/vm/src/builtins/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ impl PyRange {
(vm.ctx.types.range_type.to_owned(), range_parameters_tuple)
}

#[pymethod]
fn __getitem__(&self, subscript: PyObjectRef, vm: &VirtualMachine) -> PyResult {
match RangeIndex::try_from_object(vm, subscript)? {
RangeIndex::Slice(slice) => {
Expand Down
1 change: 0 additions & 1 deletion crates/vm/src/builtins/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,6 @@ impl PyStr {
Ok(item)
}

#[pymethod]
fn __getitem__(&self, needle: PyObjectRef, vm: &VirtualMachine) -> PyResult {
self._getitem(&needle, vm)
}
Expand Down
1 change: 0 additions & 1 deletion crates/vm/src/builtins/tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ impl PyTuple {
}
}

#[pymethod]
fn __getitem__(&self, needle: PyObjectRef, vm: &VirtualMachine) -> PyResult {
self._getitem(&needle, vm)
}
Expand Down
5 changes: 4 additions & 1 deletion crates/vm/src/builtins/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,10 @@ impl PyType {
slot_name_set.insert(name);
}
}
for attr_name in slot_name_set {
// Sort for deterministic iteration order (important for slot processing)
let mut slot_names: Vec<_> = slot_name_set.into_iter().collect();
slot_names.sort_by_key(|name| name.as_str());
for attr_name in slot_names {
self.update_slot::<true>(attr_name, ctx);
}

Expand Down
3 changes: 0 additions & 3 deletions crates/vm/src/stdlib/collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,13 @@ mod _collections {
self.maxlen
}

#[pymethod]
fn __getitem__(&self, idx: isize, vm: &VirtualMachine) -> PyResult {
let deque = self.borrow_deque();
idx.wrapped_at(deque.len())
.and_then(|i| deque.get(i).cloned())
.ok_or_else(|| vm.new_index_error("deque index out of range"))
}

#[pymethod]
fn __setitem__(&self, idx: isize, value: PyObjectRef, vm: &VirtualMachine) -> PyResult<()> {
let mut deque = self.borrow_deque_mut();
idx.wrapped_at(deque.len())
Expand All @@ -295,7 +293,6 @@ mod _collections {
.ok_or_else(|| vm.new_index_error("deque index out of range"))
}

#[pymethod]
fn __delitem__(&self, idx: isize, vm: &VirtualMachine) -> PyResult<()> {
let mut deque = self.borrow_deque_mut();
idx.wrapped_at(deque.len())
Expand Down
3 changes: 0 additions & 3 deletions crates/vm/src/stdlib/ctypes/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,6 @@ impl PyCArray {
}

// Array_subscript
#[pymethod]
fn __getitem__(zelf: &Py<Self>, item: PyObjectRef, vm: &VirtualMachine) -> PyResult {
// PyIndex_Check
if let Some(i) = item.downcast_ref::<PyInt>() {
Expand Down Expand Up @@ -1047,7 +1046,6 @@ impl PyCArray {
}

// Array_ass_subscript
#[pymethod]
fn __setitem__(
zelf: &Py<Self>,
item: PyObjectRef,
Expand All @@ -1074,7 +1072,6 @@ impl PyCArray {
}

// Array does not support item deletion
#[pymethod]
fn __delitem__(&self, _item: PyObjectRef, vm: &VirtualMachine) -> PyResult<()> {
Err(vm.new_type_error("Array does not support item deletion"))
}
Expand Down
2 changes: 0 additions & 2 deletions crates/vm/src/stdlib/ctypes/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ impl PyCPointer {
}

// Pointer_subscript
#[pymethod]
fn __getitem__(zelf: &Py<Self>, item: PyObjectRef, vm: &VirtualMachine) -> PyResult {
// PyIndex_Check
if let Some(i) = item.downcast_ref::<PyInt>() {
Expand Down Expand Up @@ -529,7 +528,6 @@ impl PyCPointer {
}

// Pointer_ass_item
#[pymethod]
fn __setitem__(
zelf: &Py<Self>,
item: PyObjectRef,
Expand Down
1 change: 0 additions & 1 deletion crates/vm/src/stdlib/sre.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,6 @@ mod _sre {
})
}

#[pymethod]
fn __getitem__(
&self,
group: PyObjectRef,
Expand Down
Loading