[Python-checkins] r46311 - in python/branches/blais-bytebuf: Doc/lib/libstdtypes.tex Include/pyport.h Lib/test/test_socket.py Python/ceval.c

martin.blais python-checkins at python.org
Fri May 26 14:34:35 CEST 2006


Author: martin.blais
Date: Fri May 26 14:34:33 2006
New Revision: 46311

Modified:
   python/branches/blais-bytebuf/Doc/lib/libstdtypes.tex
   python/branches/blais-bytebuf/Include/pyport.h
   python/branches/blais-bytebuf/Lib/test/test_socket.py
   python/branches/blais-bytebuf/Python/ceval.c
Log:
Updated blais-bytebuf to new

Modified: python/branches/blais-bytebuf/Doc/lib/libstdtypes.tex
==============================================================================
--- python/branches/blais-bytebuf/Doc/lib/libstdtypes.tex	(original)
+++ python/branches/blais-bytebuf/Doc/lib/libstdtypes.tex	Fri May 26 14:34:33 2006
@@ -728,7 +728,7 @@
 \end{methoddesc}
 
 \begin{methoddesc}[string]{partition}{sep}
-Splits the string at the first occurence of \var{sep}, and return
+Split the string at the first occurrence of \var{sep}, and return
 a 3-tuple containing the part before the separator, the separator
 itself, and the part after the separator.  If the separator is not
 found, return a 3-tuple containing the string itself, followed by

Modified: python/branches/blais-bytebuf/Include/pyport.h
==============================================================================
--- python/branches/blais-bytebuf/Include/pyport.h	(original)
+++ python/branches/blais-bytebuf/Include/pyport.h	Fri May 26 14:34:33 2006
@@ -141,6 +141,10 @@
  * convention for functions that are local to a given module.  It also enables
  * inlining, where suitable.
  *
+ * If PY_LOCAL_AGGRESSIVE is defined before python.h is included, a more
+ * "aggressive" inlining is enabled.  This may lead to code bloat, and may
+ * slow things down for those reasons.  Use with care.
+ *
  * NOTE: You can only use this for functions that are entirely local to a
  * module; functions that are exported via method tables, callbacks, etc,
  * should keep using static.
@@ -149,6 +153,10 @@
 #undef USE_INLINE /* XXX - set via configure? */
 
 #if defined(_MSC_VER)
+#if defined(PY_LOCAL_AGGRESSIVE)
+/* enable more aggressive optimization for visual studio */
+#pragma optimize("agtw", on)
+#endif
 /* ignore warnings if the compiler decides not to inline a function */ 
 #pragma warning(disable: 4710)
 /* fastest possible local call under MSVC */

Modified: python/branches/blais-bytebuf/Lib/test/test_socket.py
==============================================================================
--- python/branches/blais-bytebuf/Lib/test/test_socket.py	(original)
+++ python/branches/blais-bytebuf/Lib/test/test_socket.py	Fri May 26 14:34:33 2006
@@ -10,7 +10,6 @@
 import Queue
 import sys
 import array
-import hotbuf
 from weakref import proxy
 
 PORT = 50007
@@ -853,7 +852,6 @@
         s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
         self.assertRaises(socket.error, s.bind, address)
 
-
 class BufferIOTest(SocketConnectedTest):
     """
     Test the buffer versions of socket.recv() and socket.send().
@@ -861,117 +859,31 @@
     def __init__(self, methodName='runTest'):
         SocketConnectedTest.__init__(self, methodName=methodName)
 
-    def testRecv(self):
-        # Receive into the buffer of an array class.
+    def testRecvBuf(self):
         buf = array.array('c', ' '*1024)
         nbytes = self.cli_conn.recv_buf(buf)
         self.assertEqual(nbytes, len(MSG))
         msg = buf.tostring()[:len(MSG)]
         self.assertEqual(msg, MSG)
 
-    def _testRecv(self):
-        # Send using a read-only buffer.
+    def _testRecvBuf(self):
         buf = buffer(MSG)
         self.serv_conn.send(buf)
 
-    def testRecv2(self):
-        # Receive into a hotbuf.
-        buf = hotbuf.hotbuf(1024)
-        nbytes = self.cli_conn.recv_buf(buf)
-        self.assertEqual(nbytes, len(MSG))
-        msg = str(buf)[:len(MSG)]
-        self.assertEqual(msg, MSG)
-
-    def _testRecv2(self):
-        # Send using a hotbuf.
-## FIXME: todo
-##         buf = hotbuf.hotbuf(MSG)
-        self.serv_conn.send(MSG)
-
-##     def testOverFlowRecv(self):
-##         # Testing receive in chunks over TCP
-##         seg1 = self.cli_conn.recv(len(MSG) - 3)
-##         seg2 = self.cli_conn.recv(1024)
-##         msg = seg1 + seg2
-##         self.assertEqual(msg, MSG)
-
-##     def _testOverFlowRecv(self):
-##         self.serv_conn.send(MSG)
-
-    def testRecvFrom(self):
-        # Testing large recvfrom() over TCP
+    def testRecvFromBuf(self):
         buf = array.array('c', ' '*1024)
         nbytes, addr = self.cli_conn.recvfrom_buf(buf)
         self.assertEqual(nbytes, len(MSG))
         msg = buf.tostring()[:len(MSG)]
         self.assertEqual(msg, MSG)
 
-    def _testRecvFrom(self):
+    def _testRecvFromBuf(self):
         buf = buffer(MSG)
         self.serv_conn.send(buf)
 
-    def testRecvFrom2(self):
-        # Testing large recvfrom() over TCP
-        buf = hotbuf.hotbuf(1024)
-        nbytes, addr = self.cli_conn.recvfrom_buf(buf)
-        self.assertEqual(nbytes, len(MSG))
-        msg = str(buf)[:len(MSG)]
-        self.assertEqual(msg, MSG)
-
-    def _testRecvFrom2(self):
-        # Send using a hotbuf.
-## FIXME: todo
-##         buf = hotbuf.hotbuf(MSG)
-        self.serv_conn.send(MSG)
-
-##     def testOverFlowRecvFrom(self):
-##         # Testing recvfrom() in chunks over TCP
-##         seg1, addr = self.cli_conn.recvfrom(len(MSG)-3)
-##         seg2, addr = self.cli_conn.recvfrom(1024)
-##         msg = seg1 + seg2
-##         self.assertEqual(msg, MSG)
-
-##     def _testOverFlowRecvFrom(self):
-##         self.serv_conn.send(MSG)
-
-##     def testSendAll(self):
-##         # Testing sendall() with a 2048 byte string over TCP
-##         msg = ''
-##         while 1:
-##             read = self.cli_conn.recv(1024)
-##             if not read:
-##                 break
-##             msg += read
-##         self.assertEqual(msg, 'f' * 2048)
-
-##     def _testSendAll(self):
-##         big_chunk = 'f' * 2048
-##         self.serv_conn.sendall(big_chunk)
-
-##     def testFromFd(self):
-##         # Testing fromfd()
-##         if not hasattr(socket, "fromfd"):
-##             return # On Windows, this doesn't exist
-##         fd = self.cli_conn.fileno()
-##         sock = socket.fromfd(fd, socket.AF_INET, socket.SOCK_STREAM)
-##         msg = sock.recv(1024)
-##         self.assertEqual(msg, MSG)
-
-##     def _testFromFd(self):
-##         self.serv_conn.send(MSG)
-
-##     def testShutdown(self):
-##         # Testing shutdown()
-##         msg = self.cli_conn.recv(1024)
-##         self.assertEqual(msg, MSG)
-
-##     def _testShutdown(self):
-##         self.serv_conn.send(MSG)
-##         self.serv_conn.shutdown(2)
-
-
 def test_main():
-    tests = [GeneralModuleTests, BasicTCPTest, TCPTimeoutTest, TestExceptions]
+    tests = [GeneralModuleTests, BasicTCPTest, TCPTimeoutTest, TestExceptions,
+             BufferIOTest]
     if sys.platform != 'mac':
         tests.extend([ BasicUDPTest, UDPTimeoutTest ])
 
@@ -988,9 +900,6 @@
         tests.append(TestLinuxAbstractNamespace)
     test_support.run_unittest(*tests)
 
-def test_main2():
-    tests = [BufferIOTest]
-    test_support.run_unittest(*tests)
-
 if __name__ == "__main__":
-    test_main2()
+    test_main()
+

Modified: python/branches/blais-bytebuf/Python/ceval.c
==============================================================================
--- python/branches/blais-bytebuf/Python/ceval.c	(original)
+++ python/branches/blais-bytebuf/Python/ceval.c	Fri May 26 14:34:33 2006
@@ -6,6 +6,9 @@
    XXX document it!
    */
 
+/* enable more aggressive local inlining (platform dependent) */
+#define PY_LOCAL_AGGRESSIVE
+
 #include "Python.h"
 
 #include "code.h"
@@ -16,6 +19,11 @@
 
 #include <ctype.h>
 
+#if defined(_MSC_VER)
+/* enable more aggressive optimization for visual studio */
+#pragma optimize("agtw", on)
+#endif
+
 #ifndef WITH_TSC 
 
 #define READ_TIMESTAMP(var)
@@ -83,21 +91,21 @@
 
 /* Forward declarations */
 #ifdef WITH_TSC
-Py_LOCAL(PyObject *)call_function(PyObject ***, int, uint64*, uint64*);
+Py_LOCAL(PyObject *) call_function(PyObject ***, int, uint64*, uint64*);
 #else
-Py_LOCAL(PyObject *)call_function(PyObject ***, int);
+Py_LOCAL(PyObject *) call_function(PyObject ***, int);
 #endif
-Py_LOCAL(PyObject *)fast_function(PyObject *, PyObject ***, int, int, int);
-Py_LOCAL(PyObject *)do_call(PyObject *, PyObject ***, int, int);
-Py_LOCAL(PyObject *)ext_do_call(PyObject *, PyObject ***, int, int, int);
-Py_LOCAL(PyObject *)update_keyword_args(PyObject *, int, PyObject ***,PyObject *);
-Py_LOCAL(PyObject *)update_star_args(int, int, PyObject *, PyObject ***);
-Py_LOCAL(PyObject *)load_args(PyObject ***, int);
+Py_LOCAL(PyObject *) fast_function(PyObject *, PyObject ***, int, int, int);
+Py_LOCAL(PyObject *) do_call(PyObject *, PyObject ***, int, int);
+Py_LOCAL(PyObject *) ext_do_call(PyObject *, PyObject ***, int, int, int);
+Py_LOCAL(PyObject *) update_keyword_args(PyObject *, int, PyObject ***,PyObject *);
+Py_LOCAL(PyObject *) update_star_args(int, int, PyObject *, PyObject ***);
+Py_LOCAL(PyObject *) load_args(PyObject ***, int);
 #define CALL_FLAG_VAR 1
 #define CALL_FLAG_KW 2
 
 #ifdef LLTRACE
-Py_LOCAL(int) lltrace;
+static int lltrace;
 Py_LOCAL(int) prtrace(PyObject *, char *);
 #endif
 Py_LOCAL(int) call_trace(Py_tracefunc, PyObject *, PyFrameObject *,
@@ -108,19 +116,19 @@
 Py_LOCAL(int) maybe_call_line_trace(Py_tracefunc, PyObject *,
 				  PyFrameObject *, int *, int *, int *);
 
-Py_LOCAL(PyObject *)apply_slice(PyObject *, PyObject *, PyObject *);
+Py_LOCAL(PyObject *) apply_slice(PyObject *, PyObject *, PyObject *);
 Py_LOCAL(int) assign_slice(PyObject *, PyObject *,
 			PyObject *, PyObject *);
-Py_LOCAL(PyObject *)cmp_outcome(int, PyObject *, PyObject *);
-Py_LOCAL(PyObject *)import_from(PyObject *, PyObject *);
+Py_LOCAL(PyObject *) cmp_outcome(int, PyObject *, PyObject *);
+Py_LOCAL(PyObject *) import_from(PyObject *, PyObject *);
 Py_LOCAL(int) import_all_from(PyObject *, PyObject *);
-Py_LOCAL(PyObject *)build_class(PyObject *, PyObject *, PyObject *);
+Py_LOCAL(PyObject *) build_class(PyObject *, PyObject *, PyObject *);
 Py_LOCAL(int) exec_statement(PyFrameObject *,
 			  PyObject *, PyObject *, PyObject *);
 Py_LOCAL(void) set_exc_info(PyThreadState *, PyObject *, PyObject *, PyObject *);
 Py_LOCAL(void) reset_exc_info(PyThreadState *);
 Py_LOCAL(void) format_exc_check_arg(PyObject *, char *, PyObject *);
-Py_LOCAL(PyObject *)string_concatenate(PyObject *, PyObject *,
+Py_LOCAL(PyObject *) string_concatenate(PyObject *, PyObject *,
 				    PyFrameObject *, unsigned char *);
 
 #define NAME_ERROR_MSG \
@@ -476,7 +484,7 @@
 		WHY_YIELD =	0x0040	/* 'yield' operator */
 };
 
-static enum why_code do_raise(PyObject *, PyObject *, PyObject *);
+Py_LOCAL(enum why_code) do_raise(PyObject *, PyObject *, PyObject *);
 Py_LOCAL(int) unpack_iterable(PyObject *, int, PyObject **);
 
 /* for manipulating the thread switch and periodic "stuff" - used to be
@@ -2971,7 +2979,7 @@
 
 /* Logic for the raise statement (too complicated for inlining).
    This *consumes* a reference count to each of its arguments. */
-static enum why_code
+Py_LOCAL(enum why_code)
 do_raise(PyObject *type, PyObject *value, PyObject *tb)
 {
 	if (type == NULL) {


More information about the Python-checkins mailing list