jaysonsantos/python-binary-memcached — pull request #17 by underrun (2013-08-17 16:44:40+00:00)
Title: Python3 compatibility with working tests

Cleaned up the code a little and removed changes to the default ttl for keys (even though I think default should be 0, this patch isn't the place for it).

Test cases are passing and things seem to be working.

Open issues:

username and password are the only things automatically encoded (to utf-8 with surrogateescape bytes) if they are not already in a specified encoding. It may be better to force this interface to be bytes only like the rest of the code. it just seemed more natural to me to use the interface this way - and if auth fails it will be known upfront whereas other encoding issues could pass silently.

automatic unicode or bytes handling might be nice, but since we have to send memcached actual bytes we do need to worry about it and it can get complicated. for the purpose of interoperability, it would probably be better to require users provide strings encoded as bytes for keys and values to reduce the chance of different software storing and retrieving in different encodings.

speed can also be impacted if having to encode/decode everything where as if the programmer knows upfront to send bytes, the bytes can be prepared in bulk ahead of time.

another option might be to add 'encoding' and 'errors' attributes to the Client and allow the user to have some control over the handling of unicode serialization. but if you do this it might be necessary to provide arguments in every method to allow a specific override ... and then it gets complicated again.