Skip to content

Commit 5a60664

Browse files
committed
PyObjectView -> Py
1 parent 66b6a06 commit 5a60664

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+221
-259
lines changed

stdlib/src/array.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ mod array {
3131
AsBuffer, AsMapping, Comparable, Constructor, IterNext, IterNextIterable, Iterable,
3232
PyComparisonOp,
3333
},
34-
AsObject, PyObject, PyObjectRef, PyObjectView, PyPayload, PyRef, PyResult,
35-
VirtualMachine,
34+
AsObject, Py, PyObject, PyObjectRef, PyPayload, PyRef, PyResult, VirtualMachine,
3635
},
3736
};
3837
use itertools::Itertools;
@@ -1152,7 +1151,7 @@ mod array {
11521151

11531152
impl Comparable for PyArray {
11541153
fn cmp(
1155-
zelf: &PyObjectView<Self>,
1154+
zelf: &Py<Self>,
11561155
other: &PyObject,
11571156
op: PyComparisonOp,
11581157
vm: &VirtualMachine,
@@ -1203,7 +1202,7 @@ mod array {
12031202
}
12041203

12051204
impl AsBuffer for PyArray {
1206-
fn as_buffer(zelf: &PyObjectView<Self>, _vm: &VirtualMachine) -> PyResult<PyBuffer> {
1205+
fn as_buffer(zelf: &Py<Self>, _vm: &VirtualMachine) -> PyResult<PyBuffer> {
12071206
let array = zelf.read();
12081207
let buf = PyBuffer::new(
12091208
zelf.to_owned().into(),
@@ -1254,7 +1253,7 @@ mod array {
12541253
}
12551254

12561255
impl AsMapping for PyArray {
1257-
fn as_mapping(_zelf: &PyObjectView<Self>, _vm: &VirtualMachine) -> PyMappingMethods {
1256+
fn as_mapping(_zelf: &Py<Self>, _vm: &VirtualMachine) -> PyMappingMethods {
12581257
Self::MAPPING_METHODS
12591258
}
12601259
}
@@ -1291,7 +1290,7 @@ mod array {
12911290

12921291
impl IterNextIterable for PyArrayIter {}
12931292
impl IterNext for PyArrayIter {
1294-
fn next(zelf: &PyObjectView<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
1293+
fn next(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
12951294
let pos = zelf.position.fetch_add(1, atomic::Ordering::SeqCst);
12961295
let r = if let Some(item) = zelf.array.read().get(pos, vm) {
12971296
PyIterReturn::Return(item?)

stdlib/src/csv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ mod _csv {
99
match_class,
1010
protocol::{PyIter, PyIterReturn},
1111
types::{IterNext, IterNextIterable},
12-
AsObject, PyObjectRef, PyObjectView, PyPayload, PyResult, TryFromObject, VirtualMachine,
12+
AsObject, Py, PyObjectRef, PyPayload, PyResult, TryFromObject, VirtualMachine,
1313
};
1414
use itertools::{self, Itertools};
1515
use std::fmt;
@@ -169,7 +169,7 @@ mod _csv {
169169
impl Reader {}
170170
impl IterNextIterable for Reader {}
171171
impl IterNext for Reader {
172-
fn next(zelf: &PyObjectView<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
172+
fn next(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
173173
let string = match zelf.iter.next(vm)? {
174174
PyIterReturn::Return(obj) => obj,
175175
PyIterReturn::StopIteration(v) => return Ok(PyIterReturn::StopIteration(v)),

stdlib/src/json.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mod _json {
1010
function::OptionalArg,
1111
protocol::PyIterReturn,
1212
types::{Callable, Constructor},
13-
AsObject, PyObjectRef, PyObjectView, PyPayload, PyResult, VirtualMachine,
13+
AsObject, Py, PyObjectRef, PyPayload, PyResult, VirtualMachine,
1414
};
1515
use num_bigint::BigInt;
1616
use std::str::FromStr;
@@ -196,11 +196,7 @@ mod _json {
196196

197197
impl Callable for JsonScanner {
198198
type Args = (PyStrRef, isize);
199-
fn call(
200-
zelf: &PyObjectView<Self>,
201-
(pystr, idx): Self::Args,
202-
vm: &VirtualMachine,
203-
) -> PyResult {
199+
fn call(zelf: &Py<Self>, (pystr, idx): Self::Args, vm: &VirtualMachine) -> PyResult {
204200
if idx < 0 {
205201
return Err(vm.new_value_error("idx cannot be negative".to_owned()));
206202
}

stdlib/src/pystruct.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub(crate) mod _struct {
1616
match_class,
1717
protocol::PyIterReturn,
1818
types::{Constructor, IterNext, IterNextIterable},
19-
AsObject, PyObjectRef, PyObjectView, PyPayload, PyResult, TryFromObject, VirtualMachine,
19+
AsObject, Py, PyObjectRef, PyPayload, PyResult, TryFromObject, VirtualMachine,
2020
};
2121
use crossbeam_utils::atomic::AtomicCell;
2222

@@ -206,7 +206,7 @@ pub(crate) mod _struct {
206206
}
207207
impl IterNextIterable for UnpackIterator {}
208208
impl IterNext for UnpackIterator {
209-
fn next(zelf: &PyObjectView<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
209+
fn next(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
210210
let size = zelf.format_spec.size;
211211
let offset = zelf.offset.fetch_add(size);
212212
zelf.buffer.with_ref(|buf| {

vm/src/builtins/asyncgenerator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ impl PyAsyncGenASend {
264264

265265
impl IterNextIterable for PyAsyncGenASend {}
266266
impl IterNext for PyAsyncGenASend {
267-
fn next(zelf: &crate::PyObjectView<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
267+
fn next(zelf: &crate::Py<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
268268
PyIterReturn::from_pyresult(zelf.send(vm.ctx.none(), vm), vm)
269269
}
270270
}
@@ -410,7 +410,7 @@ impl PyAsyncGenAThrow {
410410

411411
impl IterNextIterable for PyAsyncGenAThrow {}
412412
impl IterNext for PyAsyncGenAThrow {
413-
fn next(zelf: &crate::PyObjectView<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
413+
fn next(zelf: &crate::Py<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
414414
PyIterReturn::from_pyresult(zelf.send(vm.ctx.none(), vm), vm)
415415
}
416416
}

vm/src/builtins/builtinfunc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl PyBuiltinFunction {
105105
impl Callable for PyBuiltinFunction {
106106
type Args = FuncArgs;
107107
#[inline]
108-
fn call(zelf: &crate::PyObjectView<Self>, args: FuncArgs, vm: &VirtualMachine) -> PyResult {
108+
fn call(zelf: &crate::Py<Self>, args: FuncArgs, vm: &VirtualMachine) -> PyResult {
109109
(zelf.value.func)(vm, args)
110110
}
111111
}
@@ -202,7 +202,7 @@ impl GetDescriptor for PyBuiltinMethod {
202202
impl Callable for PyBuiltinMethod {
203203
type Args = FuncArgs;
204204
#[inline]
205-
fn call(zelf: &crate::PyObjectView<Self>, args: FuncArgs, vm: &VirtualMachine) -> PyResult {
205+
fn call(zelf: &crate::Py<Self>, args: FuncArgs, vm: &VirtualMachine) -> PyResult {
206206
(zelf.value.func)(vm, args)
207207
}
208208
}

vm/src/builtins/bytearray.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use crate::{
3333
IterNextIterable, Iterable, PyComparisonOp, Unconstructible, Unhashable,
3434
},
3535
utils::Either,
36-
AsObject, PyContext, PyObject, PyObjectRef, PyObjectView, PyPayload, PyRef, PyResult,
36+
AsObject, Py, PyContext, PyObject, PyObjectRef, PyPayload, PyRef, PyResult,
3737
TryFromBorrowedObject, TryFromObject, VirtualMachine,
3838
};
3939
use bstr::ByteSlice;
@@ -303,7 +303,7 @@ impl PyByteArray {
303303
}
304304
}
305305

306-
fn irepeat(zelf: &crate::PyObjectView<Self>, n: isize, vm: &VirtualMachine) -> PyResult<()> {
306+
fn irepeat(zelf: &crate::Py<Self>, n: isize, vm: &VirtualMachine) -> PyResult<()> {
307307
if n == 1 {
308308
return Ok(());
309309
}
@@ -714,7 +714,7 @@ impl PyByteArray {
714714

715715
impl Comparable for PyByteArray {
716716
fn cmp(
717-
zelf: &crate::PyObjectView<Self>,
717+
zelf: &crate::Py<Self>,
718718
other: &PyObject,
719719
op: PyComparisonOp,
720720
vm: &VirtualMachine,
@@ -749,7 +749,7 @@ static BUFFER_METHODS: BufferMethods = BufferMethods {
749749
};
750750

751751
impl AsBuffer for PyByteArray {
752-
fn as_buffer(zelf: &PyObjectView<Self>, _vm: &VirtualMachine) -> PyResult<PyBuffer> {
752+
fn as_buffer(zelf: &Py<Self>, _vm: &VirtualMachine) -> PyResult<PyBuffer> {
753753
Ok(PyBuffer::new(
754754
zelf.to_owned().into(),
755755
BufferDescriptor::simple(zelf.len(), false),
@@ -768,16 +768,13 @@ impl<'a> BufferResizeGuard<'a> for PyByteArray {
768768
}
769769

770770
impl AsMapping for PyByteArray {
771-
fn as_mapping(_zelf: &crate::PyObjectView<Self>, _vm: &VirtualMachine) -> PyMappingMethods {
771+
fn as_mapping(_zelf: &crate::Py<Self>, _vm: &VirtualMachine) -> PyMappingMethods {
772772
Self::MAPPING_METHODS
773773
}
774774
}
775775

776776
impl AsSequence for PyByteArray {
777-
fn as_sequence(
778-
_zelf: &PyObjectView<Self>,
779-
_vm: &VirtualMachine,
780-
) -> Cow<'static, PySequenceMethods> {
777+
fn as_sequence(_zelf: &Py<Self>, _vm: &VirtualMachine) -> Cow<'static, PySequenceMethods> {
781778
Cow::Borrowed(&Self::SEQUENCE_METHODS)
782779
}
783780
}
@@ -877,7 +874,7 @@ impl Unconstructible for PyByteArrayIterator {}
877874

878875
impl IterNextIterable for PyByteArrayIterator {}
879876
impl IterNext for PyByteArrayIterator {
880-
fn next(zelf: &crate::PyObjectView<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
877+
fn next(zelf: &crate::Py<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
881878
zelf.internal.lock().next(|bytearray, pos| {
882879
let buf = bytearray.borrow_buf();
883880
Ok(PyIterReturn::from_result(

vm/src/builtins/bytes.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::{
2020
IterNextIterable, Iterable, PyComparisonOp, Unconstructible,
2121
},
2222
utils::Either,
23-
AsObject, PyContext, PyObject, PyObjectRef, PyObjectView, PyPayload, PyRef, PyResult,
23+
AsObject, Py, PyContext, PyObject, PyObjectRef, PyPayload, PyRef, PyResult,
2424
TryFromBorrowedObject, TryFromObject, VirtualMachine,
2525
};
2626
use bstr::ByteSlice;
@@ -565,7 +565,7 @@ static BUFFER_METHODS: BufferMethods = BufferMethods {
565565
};
566566

567567
impl AsBuffer for PyBytes {
568-
fn as_buffer(zelf: &PyObjectView<Self>, _vm: &VirtualMachine) -> PyResult<PyBuffer> {
568+
fn as_buffer(zelf: &Py<Self>, _vm: &VirtualMachine) -> PyResult<PyBuffer> {
569569
let buf = PyBuffer::new(
570570
zelf.to_owned().into(),
571571
BufferDescriptor::simple(zelf.len(), true),
@@ -576,16 +576,13 @@ impl AsBuffer for PyBytes {
576576
}
577577

578578
impl AsMapping for PyBytes {
579-
fn as_mapping(_zelf: &PyObjectView<Self>, _vm: &VirtualMachine) -> PyMappingMethods {
579+
fn as_mapping(_zelf: &Py<Self>, _vm: &VirtualMachine) -> PyMappingMethods {
580580
Self::MAPPING_METHODS
581581
}
582582
}
583583

584584
impl AsSequence for PyBytes {
585-
fn as_sequence(
586-
_zelf: &PyObjectView<Self>,
587-
_vm: &VirtualMachine,
588-
) -> Cow<'static, PySequenceMethods> {
585+
fn as_sequence(_zelf: &Py<Self>, _vm: &VirtualMachine) -> Cow<'static, PySequenceMethods> {
589586
Cow::Borrowed(&Self::SEQUENCE_METHODS)
590587
}
591588
}
@@ -622,14 +619,14 @@ impl PyBytes {
622619

623620
impl Hashable for PyBytes {
624621
#[inline]
625-
fn hash(zelf: &crate::PyObjectView<Self>, vm: &VirtualMachine) -> PyResult<PyHash> {
622+
fn hash(zelf: &crate::Py<Self>, vm: &VirtualMachine) -> PyResult<PyHash> {
626623
Ok(zelf.inner.hash(vm))
627624
}
628625
}
629626

630627
impl Comparable for PyBytes {
631628
fn cmp(
632-
zelf: &crate::PyObjectView<Self>,
629+
zelf: &crate::Py<Self>,
633630
other: &PyObject,
634631
op: PyComparisonOp,
635632
vm: &VirtualMachine,
@@ -698,7 +695,7 @@ impl Unconstructible for PyBytesIterator {}
698695

699696
impl IterNextIterable for PyBytesIterator {}
700697
impl IterNext for PyBytesIterator {
701-
fn next(zelf: &crate::PyObjectView<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
698+
fn next(zelf: &crate::Py<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
702699
zelf.internal.lock().next(|bytes, pos| {
703700
Ok(PyIterReturn::from_result(
704701
bytes

vm/src/builtins/complex.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ impl PyComplex {
387387

388388
impl Comparable for PyComplex {
389389
fn cmp(
390-
zelf: &crate::PyObjectView<Self>,
390+
zelf: &crate::Py<Self>,
391391
other: &PyObject,
392392
op: PyComparisonOp,
393393
vm: &VirtualMachine,
@@ -409,7 +409,7 @@ impl Comparable for PyComplex {
409409

410410
impl Hashable for PyComplex {
411411
#[inline]
412-
fn hash(zelf: &crate::PyObjectView<Self>, _vm: &VirtualMachine) -> PyResult<hash::PyHash> {
412+
fn hash(zelf: &crate::Py<Self>, _vm: &VirtualMachine) -> PyResult<hash::PyHash> {
413413
Ok(hash::hash_complex(&zelf.value))
414414
}
415415
}

vm/src/builtins/coroutine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl Unconstructible for PyCoroutine {}
108108

109109
impl IterNextIterable for PyCoroutine {}
110110
impl IterNext for PyCoroutine {
111-
fn next(zelf: &crate::PyObjectView<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
111+
fn next(zelf: &crate::Py<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
112112
Self::send(zelf.to_owned(), vm.ctx.none(), vm)
113113
}
114114
}
@@ -147,7 +147,7 @@ impl PyCoroutineWrapper {
147147

148148
impl IterNextIterable for PyCoroutineWrapper {}
149149
impl IterNext for PyCoroutineWrapper {
150-
fn next(zelf: &crate::PyObjectView<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
150+
fn next(zelf: &crate::Py<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
151151
Self::send(zelf.to_owned(), vm.ctx.none(), vm)
152152
}
153153
}

0 commit comments

Comments
 (0)