Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve os_sorted performance by avoiding Path roundtrips #157

Closed
Dobatymo opened this issue Dec 15, 2022 · 1 comment
Closed

Improve os_sorted performance by avoiding Path roundtrips #157

Dobatymo opened this issue Dec 15, 2022 · 1 comment

Comments

@Dobatymo
Copy link
Contributor

Describe the feature or enhancement
When using os_sorted on a list of Path objects they are converted to string and then back to Path.

Provide a concrete example of how the feature or enhancement will improve natsort
Avoiding this roundtrip should improve performance.

Would you be willing to submit a Pull Request for this feature?
I am not really familiar with the library yet. It looks like the conversion here

return utils.path_splitter(str(v))
could be moved to the else branch here
if not isinstance(s, PurePath):
instead

@SethMMorton
Copy link
Owner

The conversion to str(v) is because any type is technically allowed as input, but it must be a string or path object to be processed. Agreed that if the input is already Path this is extra work.

Just curious though - are you seeing a performance issue? And if so, are you sure this is the root cause of the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants