Skip to content

Commit 2288fd6

Browse files
committed
PyObjectView -> Py
1 parent 7770d79 commit 2288fd6

51 files changed

Lines changed: 223 additions & 262 deletions

Some content is hidden

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

‎stdlib/src/array.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ mod array {
3333
AsBuffer, AsMapping, Comparable, Constructor, IterNext, IterNextIterable, Iterable,
3434
PyComparisonOp,
3535
},
36-
AsPyObject, PyObject, PyObjectRef, PyObjectView, PyRef, PyResult, PyValue,
37-
TryFromBorrowedObject, TryFromObject, VirtualMachine,
36+
AsPyObject, Py, PyObject, PyObjectRef, PyRef, PyResult, PyValue, TryFromBorrowedObject,
37+
TryFromObject, VirtualMachine,
3838
},
3939
};
4040
use itertools::Itertools;
@@ -1154,7 +1154,7 @@ mod array {
11541154

11551155
impl Comparable for PyArray {
11561156
fn cmp(
1157-
zelf: &PyObjectView<Self>,
1157+
zelf: &Py<Self>,
11581158
other: &PyObject,
11591159
op: PyComparisonOp,
11601160
vm: &VirtualMachine,
@@ -1205,7 +1205,7 @@ mod array {
12051205
}
12061206

12071207
impl AsBuffer for PyArray {
1208-
fn as_buffer(zelf: &PyObjectView<Self>, _vm: &VirtualMachine) -> PyResult<PyBuffer> {
1208+
fn as_buffer(zelf: &Py<Self>, _vm: &VirtualMachine) -> PyResult<PyBuffer> {
12091209
let array = zelf.read();
12101210
let buf = PyBuffer::new(
12111211
zelf.to_owned().into(),
@@ -1256,7 +1256,7 @@ mod array {
12561256
}
12571257

12581258
impl AsMapping for PyArray {
1259-
fn as_mapping(_zelf: &PyObjectView<Self>, _vm: &VirtualMachine) -> PyMappingMethods {
1259+
fn as_mapping(_zelf: &Py<Self>, _vm: &VirtualMachine) -> PyMappingMethods {
12601260
Self::MAPPING_METHODS
12611261
}
12621262
}
@@ -1293,7 +1293,7 @@ mod array {
12931293

12941294
impl IterNextIterable for PyArrayIter {}
12951295
impl IterNext for PyArrayIter {
1296-
fn next(zelf: &PyObjectView<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
1296+
fn next(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
12971297
let pos = zelf.position.fetch_add(1, atomic::Ordering::SeqCst);
12981298
let r = if let Some(item) = zelf.array.read().get(pos, vm) {
12991299
PyIterReturn::Return(item?)

‎stdlib/src/csv.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ mod _csv {
1616
match_class,
1717
protocol::{PyIter, PyIterReturn},
1818
types::{IterNext, IterNextIterable},
19-
AsPyObject, PyObjectRef, PyObjectView, PyResult, PyValue, TryFromObject, VirtualMachine,
19+
AsPyObject, Py, PyObjectRef, PyResult, PyValue, TryFromObject, VirtualMachine,
2020
};
2121
use itertools::{self, Itertools};
2222
use std::fmt;
@@ -176,7 +176,7 @@ mod _csv {
176176
impl Reader {}
177177
impl IterNextIterable for Reader {}
178178
impl IterNext for Reader {
179-
fn next(zelf: &PyObjectView<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
179+
fn next(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
180180
let string = match zelf.iter.next(vm)? {
181181
PyIterReturn::Return(obj) => obj,
182182
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
@@ -9,7 +9,7 @@ mod _json {
99
function::{IntoPyObject, IntoPyResult, OptionalArg},
1010
protocol::PyIterReturn,
1111
types::{Callable, Constructor},
12-
AsPyObject, PyObjectRef, PyObjectView, PyResult, PyValue, VirtualMachine,
12+
AsPyObject, Py, PyObjectRef, PyResult, PyValue, VirtualMachine,
1313
};
1414
use num_bigint::BigInt;
1515
use std::str::FromStr;
@@ -195,11 +195,7 @@ mod _json {
195195

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

‎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-
AsPyObject, PyObjectRef, PyObjectView, PyResult, PyValue, TryFromObject, VirtualMachine,
19+
AsPyObject, Py, PyObjectRef, PyResult, PyValue, 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: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ use crate::{
3333
IterNextIterable, Iterable, PyComparisonOp, Unconstructible, Unhashable,
3434
},
3535
utils::Either,
36-
AsPyObject, PyContext, PyObject, PyObjectRef, PyObjectView, PyObjectWrap, PyRef, PyResult,
37-
PyValue, TryFromBorrowedObject, TryFromObject, VirtualMachine,
36+
AsPyObject, Py, PyContext, PyObject, PyObjectRef, PyObjectWrap, PyRef, PyResult, PyValue,
37+
TryFromBorrowedObject, TryFromObject, VirtualMachine,
3838
};
3939
use bstr::ByteSlice;
4040
use std::{borrow::Cow, mem::size_of};
@@ -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_object(),
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: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ use crate::{
2222
IterNextIterable, Iterable, PyComparisonOp, Unconstructible,
2323
},
2424
utils::Either,
25-
AsPyObject, PyContext, PyObject, PyObjectRef, PyObjectView, PyObjectWrap, PyRef, PyResult,
26-
PyValue, TryFromBorrowedObject, TryFromObject, VirtualMachine,
25+
AsPyObject, Py, PyContext, PyObject, PyObjectRef, PyObjectWrap, PyRef, PyResult, PyValue,
26+
TryFromBorrowedObject, TryFromObject, VirtualMachine,
2727
};
2828
use bstr::ByteSlice;
2929
use std::{borrow::Cow, mem::size_of, ops::Deref};
@@ -567,7 +567,7 @@ static BUFFER_METHODS: BufferMethods = BufferMethods {
567567
};
568568

569569
impl AsBuffer for PyBytes {
570-
fn as_buffer(zelf: &PyObjectView<Self>, _vm: &VirtualMachine) -> PyResult<PyBuffer> {
570+
fn as_buffer(zelf: &Py<Self>, _vm: &VirtualMachine) -> PyResult<PyBuffer> {
571571
let buf = PyBuffer::new(
572572
zelf.to_owned().into_object(),
573573
BufferDescriptor::simple(zelf.len(), true),
@@ -578,16 +578,13 @@ impl AsBuffer for PyBytes {
578578
}
579579

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

586586
impl AsSequence for PyBytes {
587-
fn as_sequence(
588-
_zelf: &PyObjectView<Self>,
589-
_vm: &VirtualMachine,
590-
) -> Cow<'static, PySequenceMethods> {
587+
fn as_sequence(_zelf: &Py<Self>, _vm: &VirtualMachine) -> Cow<'static, PySequenceMethods> {
591588
Cow::Borrowed(&Self::SEQUENCE_METHODS)
592589
}
593590
}
@@ -624,14 +621,14 @@ impl PyBytes {
624621

625622
impl Hashable for PyBytes {
626623
#[inline]
627-
fn hash(zelf: &crate::PyObjectView<Self>, vm: &VirtualMachine) -> PyResult<PyHash> {
624+
fn hash(zelf: &crate::Py<Self>, vm: &VirtualMachine) -> PyResult<PyHash> {
628625
Ok(zelf.inner.hash(vm))
629626
}
630627
}
631628

632629
impl Comparable for PyBytes {
633630
fn cmp(
634-
zelf: &crate::PyObjectView<Self>,
631+
zelf: &crate::Py<Self>,
635632
other: &PyObject,
636633
op: PyComparisonOp,
637634
vm: &VirtualMachine,
@@ -700,7 +697,7 @@ impl Unconstructible for PyBytesIterator {}
700697

701698
impl IterNextIterable for PyBytesIterator {}
702699
impl IterNext for PyBytesIterator {
703-
fn next(zelf: &crate::PyObjectView<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
700+
fn next(zelf: &crate::Py<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
704701
zelf.internal.lock().next(|bytes, pos| {
705702
Ok(PyIterReturn::from_result(
706703
bytes

‎vm/src/builtins/complex.rs‎

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

387387
impl Comparable for PyComplex {
388388
fn cmp(
389-
zelf: &crate::PyObjectView<Self>,
389+
zelf: &crate::Py<Self>,
390390
other: &PyObject,
391391
op: PyComparisonOp,
392392
vm: &VirtualMachine,
@@ -408,7 +408,7 @@ impl Comparable for PyComplex {
408408

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

‎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)