Add fast path for new byte inner of bytes or bytearray

This commit is contained in:
coolreader18
2019-12-04 17:54:58 -06:00
parent abb190ce50
commit bd4a492a53

View File

@@ -85,6 +85,8 @@ impl ByteInnerNewOptions {
vm.new_type_error("string argument without an encoding".to_string())
);
}
i @ PyBytes => Ok(i.get_value().to_vec()),
j @ PyByteArray => Ok(j.inner.borrow().elements.to_vec()),
obj => {
// TODO: only support this method in the bytes() constructor
if let Some(bytes_method) = vm.get_method(obj.clone(), "__bytes__") {