question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Switch to new-style callbacks

See original GitHub issue

See: https://cffi.readthedocs.io/en/latest/using.html#extern-python-new-style-callbacks

The original callbacks are slower to invoke and have the same issue as libffi’s callbacks; notably, see the warning. The new style described in the present section does not use libffi’s callbacks at all.

Occurrences of ffi.callback: https://github.com/libvips/pyvips/blob/1dc365a3beb6484d609d3aa725cd871c68af2ef0/pyvips/gvalue.py#L23 (Seems no longer used ?)

https://github.com/libvips/pyvips/blob/52e218462af9261766f5aebf60b8a39ef0c3e2c2/pyvips/__init__.py#L134 (Used by the log handler)

https://github.com/libvips/pyvips/blob/52e218462af9261766f5aebf60b8a39ef0c3e2c2/pyvips/base.py#L87 (Used by the documentation generator)

https://github.com/libvips/pyvips/blob/1dc365a3beb6484d609d3aa725cd871c68af2ef0/pyvips/voperation.py#L106 (Hot path code, used by almost all pyvips operations. Perhaps we should use vips_object_get_args for libvips 8.7+. See the lua-vips implementation)

This comment can also be solved using the new style callbacks.

After this has been resolved, we should look at https://github.com/libvips/pyvips/issues/21 again and benchmark it under cffi’s API mode (the Pillow performance test suite still depends on an older version of pyvips which doesn’t support the API mode).

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:21 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
ollie-bellcommented, Dec 23, 2021

If I do a conda install libvips cffi pkgconfig followed by pip install pyvips then it does correctly build pyvips in API mode, and is using the conda libvips binaries. Just for whatever reason, a conda install pyvips will build in ABI mode. I’ll open an issue on the conda-forge pyvips feedstock page for that.

0reactions
jcupittcommented, Dec 23, 2021

I think mixing conda and homebrew binaries in one process is not really supported and it likely to bite you at some point. My understanding (maybe wrong) is that you are supposed to use the conda libvips binaries with conda python.

(I use homebrew for everything on macos, fwiw)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Part 4: Callbacks and Symmetry - RPyC - Read the Docs
Passing a “callback function” means treating functions (or any callable objects in our case) as first-class objects, i.e., like any other value in...
Read more >
PEP 293 – Codec Error Handling Callbacks
Callbacks must be stateless, because as soon as a callback is registered it is available globally and can be called by multiple encode()...
Read more >
Creating C callbacks with @cfunc - Numba
To simplify the interoperability with C code, numba can convert a cffi type into a numba Record type using numba.core.typing.cffi_utils.map_type :.
Read more >
5. The Switch, callbacks and interrupts — MicroPython 1.9.2 ...
callback () function. The callback function sets up something to run when the switch is pressed, and uses an interrupt. It's probably best...
Read more >
JavaScript HTML DOM - Changing CSS - W3Schools
To change the style of an HTML element, use this syntax: document.getElementById(id).style.property = new style. The following example changes the style of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found