Skip to content

Commit a6dbe23

Browse files
committed
unify slots
1 parent bbc18ac commit a6dbe23

File tree

6 files changed

+1198
-977
lines changed

6 files changed

+1198
-977
lines changed

.cspell.dict/cpython.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ prec
5151
preinitialized
5252
pythonw
5353
PYTHREAD_NAME
54+
releasebuffer
5455
SA_ONSTACK
5556
SOABI
5657
stackdepth

crates/vm/src/builtins/type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ impl PyType {
465465
/// Inherit slots from base type. inherit_slots
466466
pub(crate) fn inherit_slots(&self, base: &Self) {
467467
// Use SLOT_DEFS to iterate all slots
468-
// Note: as_buffer is handled in inherit_static_slots (not AtomicCell)
468+
// Note: as_buffer is handled in inherit_readonly_slots (not AtomicCell)
469469
for def in SLOT_DEFS {
470470
def.accessor.copyslot_if_none(self, base);
471471
}

crates/vm/src/class.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn add_operators(class: &'static Py<PyType>, ctx: &Context) {
3535
}
3636

3737
// Get the slot function wrapped in SlotFunc
38-
let Some(slot_func) = def.accessor.get_slot_func(&class.slots) else {
38+
let Some(slot_func) = def.accessor.get_slot_func_with_op(&class.slots, def.op) else {
3939
continue;
4040
};
4141

crates/vm/src/protocol/number.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ pub struct PyNumberSlots {
256256
pub int: AtomicCell<Option<PyNumberUnaryFunc>>,
257257
pub float: AtomicCell<Option<PyNumberUnaryFunc>>,
258258

259+
// Right variants (internal - not exposed in SlotAccessor)
259260
pub right_add: AtomicCell<Option<PyNumberBinaryFunc>>,
260261
pub right_subtract: AtomicCell<Option<PyNumberBinaryFunc>>,
261262
pub right_multiply: AtomicCell<Option<PyNumberBinaryFunc>>,
@@ -295,8 +296,7 @@ pub struct PyNumberSlots {
295296

296297
impl From<&PyNumberMethods> for PyNumberSlots {
297298
fn from(value: &PyNumberMethods) -> Self {
298-
// right_* functions will use the same left function as PyNumberMethods
299-
// allows both f(self, other) and f(other, self)
299+
// right_* slots use the same function as left ops for native types
300300
Self {
301301
add: AtomicCell::new(value.add),
302302
subtract: AtomicCell::new(value.subtract),

0 commit comments

Comments
 (0)