pyca/pyopenssl — pull request #121 by Lukasa (2014-06-15 09:15:24+00:00)
Title: Implement Connection.recv_into.

This brings PyOpenSSL slightly closer to the standard `socket` module by providing `recv_into`.

This isn't an ideal implementation. In an ideal world the buffer object could be passed directly into the call to `SSL_read`, which would reduce this method to a single memory copy (by OpenSSL into the buffer). Instead, this method takes us to two copies (one by OpenSSL into the temp buffer, one from the temp buffer into the main buffer) and one allocation. This is better than implementing it on top of recv, which would lead to three copies and an allocation (one copy by OpenSSL into the temp buffer, one from the temp buffer into the return value, and one from the return value into the main buffer).

We can get that better performance if we can get CFFI support for [issue 65](https://bitbucket.org/cffi/cffi/issue/65/support-memoryview-to-char-conversion), but @arigo has suggested that there might be PyPy problems with that. For the moment I'd rather go ahead with this, which is imperfect but better, than wait behind CFFI-65.