From b5abd7f2f27ee0ed36edc8941c888ab22358e135 Mon Sep 17 00:00:00 2001 From: Cyril Jaquier Date: Thu, 21 Sep 2006 21:25:18 +0000 Subject: [PATCH] - Use cPickle instead of pickle. cPickle can be up to 1000 times faster git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@379 a942ae1a-1317-0410-a47c-b1dcaea8d605 --- client/csocket.py | 6 +++--- server/ssocket.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client/csocket.py b/client/csocket.py index 7f795c65..b64b8753 100644 --- a/client/csocket.py +++ b/client/csocket.py @@ -24,7 +24,7 @@ __date__ = "$Date$" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" -import socket, pickle +import socket, cPickle class CSocket: @@ -40,7 +40,7 @@ class CSocket: def send(self, msg): # Convert every list member to string - obj = pickle.dumps(map(str, msg)) + obj = cPickle.dumps(map(str, msg)) self.__csock.send(obj + CSocket.END_STRING) ret = self.receive(self.__csock) self.__csock.close() @@ -53,4 +53,4 @@ class CSocket: if chunk == '': raise RuntimeError, "socket connection broken" msg = msg + chunk - return pickle.loads(msg) + return cPickle.loads(msg) diff --git a/server/ssocket.py b/server/ssocket.py index 59ff8670..01ca99c0 100644 --- a/server/ssocket.py +++ b/server/ssocket.py @@ -25,7 +25,7 @@ __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" from threading import Thread -import socket, time, logging, pickle, os, os.path +import socket, time, logging, cPickle, os, os.path # Gets the instance of the logger. logSys = logging.getLogger("fail2ban.comm") @@ -109,7 +109,7 @@ class SocketWorker(Thread): logSys.debug("Connection closed") def __send(self, socket, msg): - obj = pickle.dumps(msg) + obj = cPickle.dumps(msg) socket.send(obj + SSocket.END_STRING) def __receive(self, socket): @@ -119,7 +119,7 @@ class SocketWorker(Thread): if chunk == '': raise RuntimeError, "socket connection broken" msg = msg + chunk - return pickle.loads(msg) + return cPickle.loads(msg) class SSocketErrorException(Exception):