r47029 - Merge static-proxy-object-8238: Create proxyForInterface(IClientRequest) type statically in twisted.web.client.
mithrandi-TA+aISz0psMTMxyoc4vAAJOcrHinNvQL0E9HWUfgJXw@public.gmane.org Fri, 18 Mar 2016 14:01:44 -0600 (MDT)
| Newsgroups | gmane.comp.python.twisted.commits |
|---|---|
| Message-ID | <[email protected]> |
Author: mithrandi
Date: Fri Mar 18 14:01:35 2016
New Revision: 47029
Added:
trunk/twisted/web/topfiles/8238.misc
Modified:
trunk/twisted/web/_newclient.py
Log:
Merge static-proxy-object-8238: Create proxyForInterface(IClientRequest) type statically in twisted.web.client.
Author: lukasa
Reviewer: mithrandi
Fixes: #8238
This improves performance of twisted-benchmarks/web on CPython by 18%,
and by 77% on PyPy.
Modified: trunk/twisted/web/_newclient.py
==============================================================================
--- trunk/twisted/web/_newclient.py (original)
+++ trunk/twisted/web/_newclient.py Fri Mar 18 14:01:35 2016
@@ -919,6 +919,14 @@
+# This proxy class is used only in the private constructor of the Response
+# class below, in order to prevent users relying on any property of the
+# concrete request object: they can only use what is provided by
+# IClientRequest.
+_ClientRequestProxy = proxyForInterface(IClientRequest)
+
+
+
@implementer(IResponse)
class Response:
"""
@@ -1012,7 +1020,7 @@
@return: L{Response} instance.
"""
response = Response(version, code, phrase, headers, _transport)
- response.request = proxyForInterface(IClientRequest)(request)
+ response.request = _ClientRequestProxy(request)
return response