Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #51651

Re: Problem with psycopg2, bytea, and memoryview

From Antoine Pitrou <solipsis@pitrou.net>
Subject Re: Problem with psycopg2, bytea, and memoryview
Date 2013-07-31 13:07 +0000
References <ktam8i$hj3$1@ger.gmane.org> <loom.20130731T114936-455@post.gmane.org> <ktat7p$t70$1@ger.gmane.org>
Newsgroups comp.lang.python
Message-ID <mailman.20.1375276076.1251.python-list@python.org> (permalink)

Show all headers | View raw


Frank Millman <frank <at> chagford.com> writes:
> 
> Thanks for that, Antoine. It is an improvement over tobytes(), but i am 
> afraid it is still not ideal for my purposes.

I would suggest asking the psycopg2 project why they made this choice, and
if they would reconsider. Returning a memoryview doesn't make much sense IMHO.

For example, the standard sqlite3 module returns bytes for BLOB columns,
and str for TEXT columns:
http://docs.python.org/3.4/library/sqlite3.html#introduction

> Can anyone explain *why* the results do not compare equal? If I understood 
> the problem, I might be able to find a workaround.

Well, under recent Python versions, they should compare equal:

Python 3.2.3 (default, Oct 19 2012, 19:53:16) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> memoryview(b"abc") == b"abc"
True


Regards

Antoine.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Problem with psycopg2, bytea, and memoryview Antoine Pitrou <solipsis@pitrou.net> - 2013-07-31 13:07 +0000

csiph-web