mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 03:04:38 +08:00
expose PyTuple::_new for PyStructSequence
This commit is contained in:
1 parent
6da45da5e7
commit
e888991da8
4 files changed
+4
-4
No files matched your search
@@ -36,7 +36,7 @@ pub(crate) fn impl_pystruct_sequence(
|
||||
self.#field_names,
|
||||
vm,
|
||||
)),*];
|
||||
::rustpython_vm::builtins::tuple::PyTuple::_new(items.into_boxed_slice())
|
||||
::rustpython_vm::builtins::tuple::PyTuple::new_unchecked(items.into_boxed_slice())
|
||||
}
|
||||
}
|
||||
impl ::rustpython_vm::IntoPyObject for #ty {
|
||||
|
||||
@@ -302,7 +302,7 @@ impl PyType {
|
||||
#[pyproperty(name = "__mro__")]
|
||||
fn get_mro(zelf: PyRef<Self>) -> PyTuple {
|
||||
let elements: Vec<PyObjectRef> = zelf.iter_mro().map(|x| x.as_object().clone()).collect();
|
||||
PyTuple::_new(elements.into_boxed_slice())
|
||||
PyTuple::new_unchecked(elements.into_boxed_slice())
|
||||
}
|
||||
|
||||
#[pyproperty(magic)]
|
||||
|
||||
@@ -115,7 +115,7 @@ 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 {
|
||||
pub fn new_unchecked(elements: Box<[PyObjectRef]>) -> Self {
|
||||
Self { elements }
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ impl PyContext {
|
||||
let false_value = create_object(PyInt::from(0), &types.bool_type);
|
||||
|
||||
let empty_tuple = create_object(
|
||||
PyTuple::_new(Vec::new().into_boxed_slice()),
|
||||
PyTuple::new_unchecked(Vec::new().into_boxed_slice()),
|
||||
&types.tuple_type,
|
||||
);
|
||||
let empty_frozenset =
|
||||
|
||||
Reference in new issue
Block a user