-
Notifications
You must be signed in to change notification settings - Fork 4
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
Api mode cffi compile #61
base: master
Are you sure you want to change the base?
Conversation
# Conflicts: # pangocffi/context.py # pangocffi/font.py # pangocffi/font_metrics.py # pangocffi/language.py
Hi George, Given that this change requires changes to both cairocffi and xcffib to add this mode (which may include changes to the final implementation pattern), I'll hold off from doing a full review. Hope that's understandable. In the meantime, here's some initial feedback: Tests The tests are failing because the enum was removed from Linting Linting is failing because of max-line-lengths and whitespace in Version bump Changes to Requiring cairocffi as a dependency Does pangocffi have to have cairocffi as a dependency in I understand pangocairocffi having cairocffi as a dependency, but in theory pangocffi is able to stand independently from cairocffi. This is because Xft could be used as the renderer, rather than Cairo. I'm unaware of anyone using this package with Xft, but my point is there's a possibility.* So I wonder if it can be removed. But correct me if I'm wrong as I'm unfamiliar with the setup that API mode requires. *I have wondered if it would make sense to merge pangocffi with pangocairocffi, as I'm guessing the primary use-case of Pango will probably be with Cairo. That would simplify a lot of things, both for maintenance and for usability. So I'm not against adding cairocffi as a dependency, I'm just explaining why pangocffi and pangocairocffi co-exist as two packages. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #61 +/- ##
==========================================
- Coverage 99.36% 98.75% -0.61%
==========================================
Files 23 23
Lines 1099 1125 +26
==========================================
+ Hits 1092 1111 +19
- Misses 7 14 +7 ☔ View full report in Codecov by Sentry. |
Thanks Lief, Working on getting cairocffi and xcffib sorted.
Done!
Fixed.
I don't think it does have to, removed for pangocffi.
Thanks for the context. I'll try and tidy up pangocairocffi changes next. |
Cffi code is much faster when compiled with a c compiler (API mode) rather than using libfffi (ABI mode) - however this requires a compiler to be installed .
This change allows an install to be made using
PANGOCFFI_API_MODE=1 CAIROCFFI_API_MODE=1 XCFFIB_API_MODE=1 pip3 install cairocffi
Various other projects (pangocffi and pangocairocffi) can then benefit from similar changes.
This change requires xcffib and cairocffi changes to be accepted - see here and here
During installation
PANGOCFFI_API_MODE=0
orPANGOCFFI_API_MODE
not set defaults to the previous ABI mode install which incurs lever overhead on load, runs the ffi_build as before and will dynamically translate arguments to C using the general libffi.During installation
PANGOCFFI_API_MODE=1
compiles a shared library / C extension which dynamically depends on xcd.At runtime if the shared library / C extension is present it will be used (unless
PANGOCFFI_API_MODE =0
). The user does not have to arrange forPANGOCFFI_API_MODE =1
to be set. If the extension is not present, the old behavior is used.To make this work I added the relevant FFI calls / setup.py calls to have the C extension be built.
I don't suggest this be default, but API mode is a potential substantial performance improvement. It also allows full speed threading as the C side unlocks the GIL.