mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 10:44:36 +08:00
PyTuple::_new to hide it from public api
This commit is contained in:
1 parent
07f898e4f0
commit
39856bc500
4 files changed
+10
-9
No files matched your search
@@ -36,7 +36,7 @@ pub(crate) fn impl_pystruct_sequence(
|
||||
self.#field_names,
|
||||
vm,
|
||||
)),*];
|
||||
items.into_boxed_slice().into()
|
||||
::rustpython_vm::obj::objtuple::PyTuple::_new(items.into_boxed_slice())
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -30,12 +30,6 @@ impl fmt::Debug for PyTuple {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Box<[PyObjectRef]>> for PyTuple {
|
||||
fn from(elements: Box<[PyObjectRef]>) -> Self {
|
||||
PyTuple { elements }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> BorrowValue<'a> for PyTuple {
|
||||
type Borrowed = &'a [PyObjectRef];
|
||||
|
||||
@@ -93,6 +87,13 @@ pub(crate) fn get_value(obj: &PyObjectRef) -> &[PyObjectRef] {
|
||||
|
||||
#[pyimpl(flags(BASETYPE), with(Hashable, Comparable))]
|
||||
impl PyTuple {
|
||||
/// Creating a new tuple with given boxed slice.
|
||||
/// NOTE: for usual case, you probably want to use PyTupleRef::with_elements.
|
||||
/// Calling this function implies trying micro optimization for non-zero-sized tuple.
|
||||
pub(crate) fn _new(elements: Box<[PyObjectRef]>) -> Self {
|
||||
Self { elements }
|
||||
}
|
||||
|
||||
#[pymethod(name = "__add__")]
|
||||
fn add(
|
||||
zelf: PyRef<Self>,
|
||||
|
||||
@@ -184,7 +184,7 @@ impl PyClass {
|
||||
#[pyproperty(name = "__mro__")]
|
||||
fn get_mro(zelf: PyRef<Self>) -> PyTuple {
|
||||
let elements: Vec<PyObjectRef> = zelf.iter_mro().map(|x| x.as_object().clone()).collect();
|
||||
elements.into_boxed_slice().into()
|
||||
PyTuple::_new(elements.into_boxed_slice())
|
||||
}
|
||||
|
||||
#[pyproperty(magic)]
|
||||
|
||||
+1
-1
@@ -140,7 +140,7 @@ impl PyContext {
|
||||
let false_value = create_object(PyInt::from(0), &types.bool_type);
|
||||
|
||||
let empty_tuple = create_object(
|
||||
PyTuple::from(Vec::new().into_boxed_slice()),
|
||||
PyTuple::_new(Vec::new().into_boxed_slice()),
|
||||
&types.tuple_type,
|
||||
);
|
||||
|
||||
|
||||
Reference in new issue
Block a user