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

Change the implementation of ObjCStrInstance #451

Closed
qqfunc opened this issue Apr 26, 2024 · 2 comments
Closed

Change the implementation of ObjCStrInstance #451

qqfunc opened this issue Apr 26, 2024 · 2 comments
Labels
enhancement New features, or improvements to existing features.

Comments

@qqfunc
Copy link
Contributor

qqfunc commented Apr 26, 2024

What is the problem or limitation you are having?

Some methods like ObjCStrInstance.__add__ use Objective-C methods now. However, converting to Python str and then adding is a faster way to do this. The same is perhaps true for the other methods.

This was my simple mistake. Using ns_from_py() at the end of the process required about the same time.

>>> string = NSString.stringWithString("some string")
>>> timeit.timeit(lambda: string + string, number=10000)
>>> timeit.timeit(lambda: ns_from_py(str(string) + str(string)), number=10000)

These require approximately the same amount of time.

Describe the solution you'd like

Just convert to Python str in the methods. Making their classes inherit collections.UserString module might be beautiful way. (It's not a well considered idea.)

Postscript: As above, this was my mistake. However, I still suggest this plan.

Describe alternatives you've considered

Maintain status quo.

Additional context

No response

@qqfunc qqfunc added the enhancement New features, or improvements to existing features. label Apr 26, 2024
@qqfunc qqfunc changed the title Improve processing speed of ObjCStrInstance Change the implementation of ObjCStrInstance Apr 26, 2024
@freakboy3742
Copy link
Member

I'm a little confused about exactly what is being requested here.

As it currently stands, there's a clear line between NSString and str, and a clear point at which the strings change. On that basis, I don't think it's worth complicating both the interface and implementation - especially when, by your own analysis, it won't be any faster.

@qqfunc
Copy link
Contributor Author

qqfunc commented Apr 27, 2024

I am so sorry for the confusion.
This is now my vague idea and doesn't seem worth suggesting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features, or improvements to existing features.
Projects
None yet
Development

No branches or pull requests

2 participants