Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
5e74742b
Commit
5e74742b
authored
Jun 18, 2018
by
Jason Madden
Committed by
GitHub
Jun 18, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1241 from gevent/issue1233
Use bytearray += instead of bytearray.extend
parents
23cc4322
fcbdd238
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
13 deletions
+15
-13
CHANGES.rst
CHANGES.rst
+3
-0
src/gevent/pywsgi.py
src/gevent/pywsgi.py
+12
-13
No files found.
CHANGES.rst
View file @
5e74742b
...
@@ -16,6 +16,9 @@
...
@@ -16,6 +16,9 @@
way :mod:`gevent.pywsgi` generates HTTP chunks. This is intended to
way :mod:`gevent.pywsgi` generates HTTP chunks. This is intended to
reduce network overhead, especially for smaller chunk sizes.
reduce network overhead, especially for smaller chunk sizes.
- Additional slight performance improvements in :mod:`gevent.pywsgi`.
See :pr:`1241`.
1.3.3 (2018-06-08)
1.3.3 (2018-06-08)
==================
==================
...
...
src/gevent/pywsgi.py
View file @
5e74742b
...
@@ -733,9 +733,9 @@ class WSGIHandler(object):
...
@@ -733,9 +733,9 @@ class WSGIHandler(object):
towrite
=
_bytearray
(
header_str
)
towrite
=
_bytearray
(
header_str
)
# data
# data
towrite
.
extend
(
data
)
towrite
+=
data
# trailer
# trailer
towrite
.
extend
(
b'
\
r
\
n
'
)
towrite
+=
b'
\
r
\
n
'
self
.
_sendall
(
towrite
)
self
.
_sendall
(
towrite
)
else
:
else
:
self
.
_sendall
(
data
)
self
.
_sendall
(
data
)
...
@@ -756,21 +756,20 @@ class WSGIHandler(object):
...
@@ -756,21 +756,20 @@ class WSGIHandler(object):
self
.
_write_with_headers
(
data
)
self
.
_write_with_headers
(
data
)
def
_write_with_headers
(
self
,
data
):
def
_write_with_headers
(
self
,
data
):
towrite
=
bytearray
()
self
.
headers_sent
=
True
self
.
headers_sent
=
True
self
.
finalize_headers
()
self
.
finalize_headers
()
# self.response_headers and self.status are already in latin-1, as encoded by self.start_response
# self.response_headers and self.status are already in latin-1, as encoded by self.start_response
towrite
.
extend
(
b'HTTP/1.1 '
)
towrite
=
bytearray
(
b'HTTP/1.1 '
)
towrite
.
extend
(
self
.
status
)
towrite
+=
self
.
status
towrite
.
extend
(
b'
\
r
\
n
'
)
towrite
+=
b'
\
r
\
n
'
for
header
,
value
in
self
.
response_headers
:
for
header
,
value
in
self
.
response_headers
:
towrite
.
extend
(
header
)
towrite
+=
header
towrite
.
extend
(
b': '
)
towrite
+=
b': '
towrite
.
extend
(
value
)
towrite
+=
value
towrite
.
extend
(
b"
\
r
\
n
"
)
towrite
+=
b"
\
r
\
n
"
towrite
.
extend
(
b'
\
r
\
n
'
)
towrite
+=
b'
\
r
\
n
'
self
.
_sendall
(
towrite
)
self
.
_sendall
(
towrite
)
# No need to copy the data into towrite; we may make an extra syscall
# No need to copy the data into towrite; we may make an extra syscall
# but the copy time could be substantial too, and it reduces the chances
# but the copy time could be substantial too, and it reduces the chances
...
@@ -914,8 +913,8 @@ class WSGIHandler(object):
...
@@ -914,8 +913,8 @@ class WSGIHandler(object):
# Trigger the flush of the headers.
# Trigger the flush of the headers.
self
.
write
(
b''
)
self
.
write
(
b''
)
if
self
.
response_use_chunked
:
if
self
.
response_use_chunked
:
self
.
socket
.
sendall
(
b'0
\
r
\
n
\
r
\
n
'
)
self
.
_
sendall
(
b'0
\
r
\
n
\
r
\
n
'
)
self
.
response_length
+=
5
def
run_application
(
self
):
def
run_application
(
self
):
assert
self
.
result
is
None
assert
self
.
result
is
None
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment