Skip to content

Commit cf4a5f3

Browse files
committed
Remove unused PyLease
PyLease wrapped a read guard over the object's type when `typ` was a `PyRwLock<PyTypeRef>`. Its last users, `class()` and `lease_class()`, went away when `typ` became a `PyAtomicRef<PyType>` (#3828). Its field is private and it has no constructor, so it cannot be built anywhere. Assisted-by: Claude Code:claude-opus-5-5
1 parent 393689d commit cf4a5f3

1 file changed

Lines changed: 1 addition & 44 deletions

File tree

‎crates/vm/src/object/ext.rs‎

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ use super::{
22
core::{Py, PyObject, PyObjectRef, PyRef},
33
payload::PyPayload,
44
};
5-
use crate::common::{
6-
atomic::{Ordering, PyAtomic, Radium},
7-
lock::PyRwLockReadGuard,
8-
};
5+
use crate::common::atomic::{Ordering, PyAtomic, Radium};
96
use crate::{
107
VirtualMachine,
118
builtins::{PyBaseExceptionRef, PyStrInterned, PyType},
@@ -729,46 +726,6 @@ impl PyObject {
729726
// }
730727
// }
731728

732-
/// A borrow of a reference to a Python object. This avoids having clone the `PyRef<T>`/
733-
/// `PyObjectRef`, which isn't that cheap as that increments the atomic reference counter.
734-
// TODO: check if we still need this
735-
#[allow(dead_code)]
736-
pub struct PyLease<'a, T: PyPayload> {
737-
inner: PyRwLockReadGuard<'a, PyRef<T>>,
738-
}
739-
740-
impl<T: PyPayload> PyLease<'_, T> {
741-
#[inline(always)]
742-
#[must_use]
743-
pub fn into_owned(self) -> PyRef<T> {
744-
self.inner.clone()
745-
}
746-
}
747-
748-
impl<T: PyPayload> Borrow<PyObject> for PyLease<'_, T> {
749-
#[inline(always)]
750-
fn borrow(&self) -> &PyObject {
751-
self.inner.as_ref()
752-
}
753-
}
754-
755-
impl<T: PyPayload> Deref for PyLease<'_, T> {
756-
type Target = PyRef<T>;
757-
#[inline(always)]
758-
fn deref(&self) -> &Self::Target {
759-
&self.inner
760-
}
761-
}
762-
763-
impl<T> fmt::Display for PyLease<'_, T>
764-
where
765-
T: PyPayload + fmt::Display,
766-
{
767-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
768-
fmt::Display::fmt(&**self, f)
769-
}
770-
}
771-
772729
impl<T: PyPayload> ToPyObject for PyRef<T> {
773730
#[inline(always)]
774731
fn to_pyobject(self, _vm: &VirtualMachine) -> PyObjectRef {

0 commit comments

Comments
 (0)