Skip to content
This repository has been archived by the owner on Sep 27, 2021. It is now read-only.

Use opportunistic zero-copy strategy in send #35

Merged
merged 1 commit into from
Sep 20, 2016
Merged

Conversation

mayfield
Copy link
Contributor

Use ffi.from_buffer more aggressively when the data type and CFFI version
support it. Older versions of CFFI don't support commonly used types
like bytes but do work for some variants of memoryview. Instead of
instance and version checking all the permutations this patch attempts the
fast path first and catches TypeError as a condition to degrade to the slow
path of ffi.new.

See: http://cffi.readthedocs.io/en/latest/ref.html#ffi-buffer-ffi-from-buffer

Fixes #34

Use `ffi.from_buffer` more aggressively when the data type and CFFI version
support it.  Older versions of CFFI don't support commonly used types
like `bytes` but do work for some variants of `memoryview`.  Instead of
instance and version checking all the permutations this patch attempts the
fast path first and catches `TypeError` as a condition to degrade to the slow
path of `ffi.new`.

See: http://cffi.readthedocs.io/en/latest/ref.html#ffi-buffer-ffi-from-buffer

Fixes nanomsg#34
@djc djc merged commit 5269d26 into nanomsg:master Sep 20, 2016
@djc
Copy link
Member

djc commented Sep 20, 2016

Thank you for getting this done!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants