penguin-wwy opened a new pull request, #1970: URL: https://github.com/apache/fury/pull/1970
## What does this PR do? In Python, to implement a linear memory structure that stores key-value pairs, we can traverse them in the order of insertion like accessing an array. However, Cython does not provide a direct access interface, and these interfaces are internal in CPython, requiring compatibility work to use them correctly. Nevertheless, we can still use the`PyDict_Next` interface to replace the `items` method. Essentially, `items` use `PyDict_Next` to append to a list. Doing so can reduce the copying overhead. ## Related issues ## Does this PR introduce any user-facing change? - [ ] Does this PR introduce any public API change? - [ ] Does this PR introduce any binary protocol compatibility change? ## Benchmark For large dict ``` [dict_item] 541 us +- 39 us -> [dict_next] 535 us +- 35 us: 1.00x faster [dict_item] 119.8 MiB +- 1344.0 KiB -> [dict_next] 118.8 MiB +- 1338.4 KiB: 1.01x faster ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
