harfbuzz / uharfbuzz

A HarfBuzz Python binding
Apache License 2.0
68 stars 25 forks source link

[draw API] Get another 10-15% speedup by pre-fetching the pen instance methods #135

Closed justvanrossum closed 2 years ago

justvanrossum commented 2 years ago

Pre-fetching the pen instance methods and passing them via user_data speeds up pen drawing by another 10-15%.

behdad commented 2 years ago

I'm glad you are finding the user_data useful!

justvanrossum commented 2 years ago

I'm glad you are finding the user_data useful!

Totally! It appears to me this is exactly what user_data is good at: passing method-specific implementations. DrawFuncs objects should do the same for the pure Python callbacks.

behdad commented 2 years ago

Totally! It appears to me this is exactly what user_data is good at: passing method-specific implementations

Correct. That's what they are for.

behdad commented 2 years ago

Typically the user_data is bound to the method to call for that particular call, whereas the draw_data is bound to the instance.

behdad commented 2 years ago

I've got to say what you and Khaled are doing with this API is all magic to me.

justvanrossum commented 2 years ago

Right. In this case user_data is both, as I'm using it to pass bound methods.

khaledhosny commented 2 years ago

I've got to say what you and Khaled are doing with this API is all magic to me.

A well designed API allows its users to do things not imagined by its designers 😉 (I think there was a saying somehow like that, or may be I’m making things up)