BlobField not converted to bytes on Python 3.3+ and Postgresql
A `memoryview` is just a pointer to a buffer of bytes. It can be indexed, sliced, etc without incurring an allocation and copy. This is a very important optimization to retain when the database-driver supports it (eg psycopg2). Your example field is exactly how I would work-around this if your code depends on having a `bytes` object instead.

For what it's worth, most APIs support using `memoryview` just as they would `bytes` or `bytearray`...you can write them to a file, etc., so if you are running into some kind of compatibility issue you might consider addressing it upstream. > For what it's worth, most APIs support using memoryview just as they would bytes or bytearray...you can write them to a file, etc., so if you are running into some kind of compatibility issue you might consider addressing it upstream.
 
Yeah fair enough - hopefully the next person switching from Py2 to Py3 will find this issue and understands how to solve it without having to change lots of application logic.. 😁 Many python 2.x drivers return `buffer` type. Python 2.7 also has memoryview and bytearray, so it really just depends on the driver you're using.
Due to psycopg2 converting Postgres' `bytea` data to `memoryview` objects starting with Python 3.3, models with `BlobField`s require special care:

Data needs to be converted to bytes via `tobytes()` to achieve expected behavior.

Right now Peewee's core implementation doesn't seem to take this into account (the tests seem to check for this and apply `tobytes` themselves), which would require a project to either implement a Postgres-only conversion step _or_ create a custom field that handles the conversion, à la:

```
class Py3Blob(BlobField):
    def python_value(self, value):
        if isinstance(value, memoryview):
            return value.tobytes()
        else:
            return super().python_value(value)
```

IIRC the motivation behind using `memoryview` was to use a more memory-efficient data type for actually big blobs (e.g. image data) that wouldn't require copying that data around, which is a valid concern and might make automatically converting this data to bytes a no-go.

Is there a chance for Peewee nevertheless converting to bytes itself to align Py3 behavior for  `BlobField`s with Py2, especially as the Model wouldn't return different types based on backend _and_ Python version or maybe a "watch out for this, fix with custom field" warning in the docs?