expose PyTuple::_new for PyStructSequence

This commit is contained in:
Jeong YunWon committed 2021-10-01 01:54:04 +09:00
1 parent 6da45da5e7
commit e888991da8
4 files changed
+4 -4

No files matched your search

+1 -1
View File
@@ -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 {
+1 -1
View File
@@ -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)]
+1 -1
View File
@@ -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
View File
@@ -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 =