-
Notifications
You must be signed in to change notification settings - Fork 18k
x/pkgsite: Can we add get and set methods to retrieve and set specific slice types into reflect pkg? #70267
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
Comments
Related Code Changes (Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.) |
The suggested is whole other different issue @gabyhelp. |
reflect is intended to allow operations the language can do without the use of unsafe. This would be our of scope for the package. |
But does it not makes use a lot of unsafe operations in a "safer" way? |
The implementation may use unsafe, but it's not a dumping ground for wrapping unsafe operations. The exposed API matches what the language naturally allows. |
And would there be a way we would be able to encapsulate those methos on a |
Given it's not something we endorse or would want to maintain, there's no reason to put it under x/. You can have your own package wrapping unsafe operations if you wish. |
I was thinking of that. However, accessing the Value.ptr is up to 40% faster than conducting an operation after calling The case is that I have built a serializer. The serialzier is about 20% faster with typed safe operations compared to the proto serializer except for []int and []uint type slices which is about 15% slower (Bytes, mine is faster, though). That is why I was trying to find an as fast as alternative. Do you have any thoughts or suggestion? Should I be content with the performance I can get using typed safety already? Spin-off the unsafe version into a different pkg and yet be satisfied as well? Thanks in advance. |
What is the URL of the page with the issue?
https://github.com/Pietroski/go-serializer
What is your user agent?
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Screenshot
No response
What did you do?
I was wondering to know if we (I) can add new reflect methods to get and set []int sices. With the methos I manually added and tested locally I saw a 40%-60% performance increase compared to the current available methos to getting a slice type from a slice or an array.
What I did and was thingking were specific (or we can craft more generic ones too) and explicit ways to return and easily set []int64, []uint64, []int32, []uint32 and so on...
What did you see happen?
With the methos I manually added and tested locally I saw a 40%-60% performance increase compared to the current available methos to getting a slice type from a slice or an array.
What did you expect to see?
I expect that by implementing those methods it will help make serializer / encoding algorithims faster and reduce the usage of unsafe to keep them performant.
The text was updated successfully, but these errors were encountered: