Fapws-Python3 is now working ;-)

48 views
Skip to first unread message

william opensource4you

unread,
Jan 22, 2012, 4:58:22 AM1/22/12
to fapws
All,

I've just pushed the first working release of Fapws with Python3 ;-).
(branch called python3)
Because of changes made in PYthon3, lot of internal codes have change.

The only test/sample currently working is the one present in
tests/unittests !!!!!.
With the simple "Hello World!!" sample, I observe a decrease of +-5%
of the performance (on a linux server, thus with epoll): 5675#/sec
with python-3.2 and 5951 with python-2.7.
It's rather difficult to say if this delta is coming from python or
from my changes in Fapws. Most probably the unicode - bytes conversion
cost the most.

After this rather long and complex dive into the new PYthon language
(python3 is so much different than python2); I must say that I find
the concept of bytes is very well welcome and avoid some weird side
effects. But unfortunately the change in Python3.2 are not limited to
that.

But the most tricky part is concerning the WSGI rules it self ??!!!???
Indeed everybody has his own interpretation of how wsgi-1.0 must evolve ;-(.
Just look at this page to see the different interpretations:
http://www.wsgi.org/en/latest/python3.html#proposals

Currently implemented in fapws is the "wsgi-1.0"; in other words all
old-string elements have been converted to bytes.

For the Wsgi developpers this means that "environ" and
"start_response" must be fully in bytes (keys and values).

I don't know if this is the best approach ;-(.
Let me know what you think and let's have a discussion.

Checkout the python3 release of the code to test it.

William

ps:
other samples must still be translated to python3 ;-(.

Jonas H.

unread,
Jan 22, 2012, 5:50:33 AM1/22/12
to fa...@googlegroups.com
On 01/22/2012 10:58 AM, william opensource4you wrote:
> But the most tricky part is concerning the WSGI rules it self ??!!!???
> Indeed everybody has his own interpretation of how wsgi-1.0 must evolve ;-(.
> Just look at this page to see the different interpretations:
> http://www.wsgi.org/en/latest/python3.html#proposals
>
> Currently implemented in fapws is the "wsgi-1.0"; in other words all
> old-string elements have been converted to bytes.

PEP 3333 has been accepted as the official way to do WSGI with Python 3
months ago by Guido van Rossum. So no need to worry about multiple
standards :-)

--
http://jonas.lophus.org | http://django-mongodb.org

william opensource4you

unread,
Jan 22, 2012, 6:32:12 AM1/22/12
to fa...@googlegroups.com
Indeed, but I can read and re-read the pep 3333 I don't find clearly
what should be string and what should be bytes.

Is there a simple summary table around ?

Up to know I've implemented the rule saying that every py2-string
should be py3-bytes.

Jonas H.

unread,
Jan 22, 2012, 7:07:44 AM1/22/12
to fa...@googlegroups.com
On 01/22/2012 12:32 PM, william opensource4you wrote:
> Indeed, but I can read and re-read the pep 3333 I don't find clearly
> what should be string and what should be bytes.

It's pretty simple actually. Use native strings for environ keys and
values and bytes for `wsgi.input` and the result iterator -- in short,
bytestrings for "bodies" and native strings for everything else.

Reply all
Reply to author
Forward
0 new messages