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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ repos:

- id: generate-rs-opcode-metadata
name: generate rust opcode metadata
entry: python tools/opcode_metadata/generate_rs_opcode_metadata.py
entry: python3 tools/opcode_metadata/generate_rs_opcode_metadata.py
files: '^(crates/compiler-core/src/bytecode/instruction\.rs|tools/opcode_metadata/*)$'
pass_filenames: false
language: system
Expand All @@ -53,7 +53,7 @@ repos:

- id: generate-py-opcode-metadata
name: generate python opcode metadata
entry: python tools/opcode_metadata/generate_py_opcode_metadata.py
entry: python3 tools/opcode_metadata/generate_py_opcode_metadata.py
files: '^(crates/compiler-core/src/bytecode/instruction\.rs|tools/opcode_metadata/*)$'
pass_filenames: false
language: system
Expand Down
9 changes: 6 additions & 3 deletions crates/vm/src/builtins/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,15 @@ impl PyList {

if let Some(index) = index.into() {
// defer delete out of borrow
let is_inside_range = index < self.borrow_vec().len();
Ok(is_inside_range.then(|| self.borrow_vec_mut().remove(index)))
let removed = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure how creating removed helps here. what does it hold and why do we need removed variable?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the main change was to call .borrow_vec_mut() once instead of twice

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, in the summary: Reduce list.remove() from two lock acquisitions to one

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

let mut elements = self.borrow_vec_mut();
(index < elements.len()).then(|| elements.remove(index))
};
drop(removed);
Ok(())
} else {
Err(vm.new_value_error(format!("'{}' is not in list", needle.str(vm)?)))
}
.map(drop)
}

fn _delitem(&self, needle: &PyObject, vm: &VirtualMachine) -> PyResult<()> {
Expand Down
2 changes: 1 addition & 1 deletion scripts/check_redundant_patches.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import argparse
import ast
import glob
Expand Down
Loading