diff options
author | ben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2002-06-17 03:24:05 +0000 |
---|---|---|
committer | ben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2002-06-17 03:24:05 +0000 |
commit | 6b72b10acde7061c1180a59d6eea3c0c20780683 (patch) | |
tree | 1284913e6d64c09994149f0da28551029b522731 /rdiff-backup/rdiff_backup/connection.py | |
parent | 30a98a1fa0d78837915e9b26b35c9abfd0783cf3 (diff) | |
download | rdiff-backup-6b72b10acde7061c1180a59d6eea3c0c20780683.tar.gz |
Many optimizations - up to 3x speed improvement
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@134 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/rdiff_backup/connection.py')
-rw-r--r-- | rdiff-backup/rdiff_backup/connection.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/rdiff-backup/rdiff_backup/connection.py b/rdiff-backup/rdiff_backup/connection.py index 74d413d..c557dd5 100644 --- a/rdiff-backup/rdiff_backup/connection.py +++ b/rdiff-backup/rdiff_backup/connection.py @@ -1,5 +1,5 @@ from __future__ import generators -import types, os, tempfile, cPickle, shutil, traceback +import types, os, tempfile, cPickle, shutil, traceback, pickle ####################################################################### # @@ -119,7 +119,8 @@ class LowLevelPipeConnection(Connection): def _putobj(self, obj, req_num): """Send a generic python obj down the outpipe""" - self._write("o", cPickle.dumps(obj, 1), req_num) + # for some reason there is an error when cPickle is used below.. + self._write("o", pickle.dumps(obj, 1), req_num) def _putbuf(self, buf, req_num): """Send buffer buf down the outpipe""" @@ -181,7 +182,8 @@ class LowLevelPipeConnection(Connection): def _write(self, headerchar, data, req_num): """Write header and then data to the pipe""" - self.outpipe.write(headerchar + chr(req_num) + self._l2s(len(data))) + self.outpipe.write(headerchar + chr(req_num) + + C.long2str(long(len(data)))) self.outpipe.write(data) self.outpipe.flush() @@ -189,14 +191,14 @@ class LowLevelPipeConnection(Connection): """Read length bytes from inpipe, returning result""" return self.inpipe.read(length) - def _s2l(self, s): + def _s2l_old(self, s): """Convert string to long int""" assert len(s) == 7 l = 0L for i in range(7): l = l*256 + ord(s[i]) return l - def _l2s(self, l): + def _l2s_old(self, l): """Convert long int to string""" s = "" for i in range(7): @@ -214,7 +216,7 @@ class LowLevelPipeConnection(Connection): try: format_string, req_num, length = (header_string[0], ord(header_string[1]), - self._s2l(header_string[2:])) + C.str2long(header_string[2:])) except IndexError: raise ConnectionError() if format_string == "q": raise ConnectionQuit("Received quit signal") @@ -490,7 +492,7 @@ class VirtualFile: # everything has to be available here for remote connection's use, but # put at bottom to reduce circularities. -import Globals, Time, Rdiff, Hardlink, FilenameMapping +import Globals, Time, Rdiff, Hardlink, FilenameMapping, C from static import * from lazy import * from log import * |