Thanks to visit codestin.com
Credit goes to Github.com

Skip to content
This repository was archived by the owner on Apr 22, 2025. It is now read-only.

Conversation

@ssidorenko
Copy link

No description provided.

Copy link

@Horusiath Horusiath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few changes proposed to reduce intermediate allocations when doing type conversions. Overall kudos: that's nice piece of good work 👍

CompatiblePyType::String(s) => Ok(Any::String(s.extract::<String>()?.into_boxed_str())),
CompatiblePyType::String(s) => {
let string = s.extract::<String>()?;
let arc_str = Arc::from(string.as_str());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If s.extract::<Arc<str>>() don't work, this could be Arc::from(string) directly.

.map(|py_any| CompatiblePyType::try_from(py_any)?.try_into())
.collect();
result.map(|res| Any::Array(res.into_boxed_slice()))
result.map(|res| Any::Array(Arc::from(res.into_boxed_slice())))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if .into_boxed_slice is needed. Possibly Arc::from(res) or Arc::from(res.as_slice()) could work as well without intermediate allocations.

@alexlopashev
Copy link

Most probably superseded by #156

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants