-
Notifications
You must be signed in to change notification settings - Fork 555
Speed up creating Mark objects in the Cython version #848
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
base: main
Are you sure you want to change the base?
Conversation
|
Thanks, this looks like some low-hanging fruit for a nice speed boost! I don't love changing all the Cython callsites to use the two-call pattern, though... I might try playing with a cdef factory method that could accomplish the same thing with a single callsite (or feel free to do so yourself if you're interested!)- IIRC we've got a lot of flexibility there since we're not worried about non-Cython subclasses of this |
|
I didn't make a helper because Cython would end up ref counting the Mark object being passed around in the helper.. It might not make much difference though. Will test |
|
Still a nice speed up even with the helper. Note that 3.1 got a bit faster already since I opened this PR With Cython 3.1
|
|
Pushed another one that a bit different. Single call point but it does have a bit more maintenance burden. 688ebe7 |
main 192,792,792ns
this PR 168,216,041ns
Benchmark https://github.com/bdraco/pyyaml/blob/bench/tests_bench/benchmarks/test_simple_load.py (execute with
pytest --codspeed tests_bench/benchmarks/test_simple_load.py)Cython analysis via
cythonize -X language_level=3 -a -i yaml/_yaml.pyxBefore

After
