uvloop icon indicating copy to clipboard operation
uvloop copied to clipboard

Expose uv_loop_t pointer for integration with other C-extensions

Open pranavtbhat opened this issue 5 years ago • 5 comments

This PR adds a couple of functions to expose the raw uvloop pointer as int/pycapsule. #307

I can remove the int one if we feel it's not required.

pranavtbhat avatar Jan 17 '20 03:01 pranavtbhat

uint64_t is not guaranteed to be the size of void *, why not use the dedicated feature and get it right with one single function?

ghost avatar Jan 17 '20 12:01 ghost

@1st1 Your thoughts on pycapsule vs int?

pranavtbhat avatar Jan 21 '20 17:01 pranavtbhat

The build failure looks unrelated.

pranavtbhat avatar Jan 29 '20 23:01 pranavtbhat

My +1 on this feature; regarding uint64_t, uintptr_t may be better. FWIW there are existing libraries exposing pointers as integers (e.g. numpy.ndarray.ctypes.data); integers are easier to work with when using cffi.

XeCycle avatar Jun 07 '21 04:06 XeCycle

Hello, I'm interested in this feature and actually was checking outstanding pull requests before submitting my own. Looking over the above the failed check seems unrelated but as reviewer noted the integer should be uintptr_t not uint64_t. I'm not sure how/if it's possible for me to patch the submitted pull request. Should I submit my own?

jensbjorgensen avatar Apr 26 '22 15:04 jensbjorgensen

Thanks for the PR and sorry for the delay! I think having an int pointer in Python doesn't make much sense - it'll be used in a C context anyways, so I think it's fine to only go with the standard API. (I was suggesting the Cython API in another PR, but I like the capsule better - just importing is sufficient, no linking needed!)

I pushed a fix with a Cython test that actually checks the encapsulated pointers.

fantix avatar Aug 13 '22 19:08 fantix

Two questions on this

  • Is there a new uvloop release on the horizon that includes this feature? ;)

  • Any words of caution concerning libuv API compatibility? Is uvloop using a statically linked libuv library or a shared library that we'd re-use in a c-extension? Does uvloop use a vanilla libuv for which we can expect SemVer ABI stability?

pwuertz avatar Aug 28 '22 08:08 pwuertz

  • Is there a new uvloop release on the horizon that includes this feature? ;)

Yes, we'll try to release a new version in the next week or two.

  • Any words of caution concerning libuv API compatibility?

Hmm we should probably re-export some of the libuv version-checking utils if we're statically linking, @1st1 wdyt?

Is uvloop using a statically linked libuv library or a shared library that we'd re-use in a c-extension?

This depends, by default it is statically linked but this can be override with the --use-system-libuv option.

Does uvloop use a vanilla libuv for which we can expect SemVer ABI stability?

Yes, https://github.com/MagicStack/uvloop/tree/master/vendor

fantix avatar Aug 28 '22 14:08 fantix

  • Any words of caution concerning libuv API compatibility?

Hmm we should probably re-export some of the libuv version-checking utils if we're statically linking, @1st1 wdyt?

uv_version() is now exposed in #491.

fantix avatar Sep 09 '22 14:09 fantix