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.

Replace `ffi.callback()` with `ffi.def_extern()`

See original GitHub issue

Create a new issue to track the ffi.callback() cause MemoryError on macOS M1.

See comment of @bastibe in https://github.com/bastibe/python-soundfile/issues/325#issuecomment-1048584002

According to https://cffi.readthedocs.io/en/latest/using.html#callbacks, ffi.callback() is old style callback, and has many drawbacks, should be replaced by new style callback def_extern().

I’ve looked into this, and actually drafted an implementation of the callbacks locally. However, there is a problem with this approach: Currently, we are using the ABI mode of CFFI. The “new style” callbacks you mentioned require that soundfile uses the API mode of CFFI, which means compiling a bespoke version of soundfile for every operating system and version of Python we support.

While I am certainly open to doing this, especially now that we have CI runners to automate the task, I think it is out-of-scope for this pull request. Please raise the issue in a new issue, or preferably, try to draft a pull request for it.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
f17mkxcommented, Apr 27, 2022

i’m dead

0reactions
aghrisscommented, Jul 13, 2022

@f17mkx the package from that comment did not work for me. @hiccup7 I’m working with @bastibe to push an update. You can try the wheel here. I tested it on M1 and it works (install via pip)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using the ffi/lib objects — CFFI 1.15.1 documentation
Only ffi.typeof() works on them. To get a cdata containing a regular function pointer, use ffi.addressof(lib, " ...
Read more >
Writing abstractions for FFI callback interfaces - casualhacks.net
Creating an abstraction for this is pretty simple. Keep in mind that the API only allows us to pass a thin pointer and...
Read more >
[pypy-commit] cffi default: Move the FFI Interface and ...
__: using.html#def-extern -. ... XXXXXXXXXXX + + +ffi.buffer(), ffi.from_buffer() ... or write into it to change the original value.
Read more >
FFI Haskell Callback with State - Stack Overflow
this is the function that C will call back syncWithC :: MVar CInt -> CInt -> IO () syncWithC m x = do...
Read more >
File: Callbacks — FFI master - Doc Index
FFI supports the mapping of Ruby closures (Proc, lambda) to C function pointers, and it also supports passing in a function pointer that...
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