X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=bencode.py;h=b3f9a68ad3ffa6e3015c167b70346d7cb3be87ef;hb=1c86839bee11f2af73d71ed76c4d3eccbac4f316;hp=93af40744a6365578f7aa4b1589a98c451fe49f4;hpb=67ea324e46570a42861fe6a342c626738134bbfc;p=quix0rs-apt-p2p.git diff --git a/bencode.py b/bencode.py index 93af407..b3f9a68 100644 --- a/bencode.py +++ b/bencode.py @@ -2,10 +2,10 @@ # see LICENSE.txt for license information from types import IntType, LongType, StringType, ListType, TupleType, DictType -import re +from re import compile from cStringIO import StringIO -int_filter = re.compile('(0|-?[1-9][0-9]*)e') +int_filter = compile('(0|-?[1-9][0-9]*)e') def decode_int(x, f): m = int_filter.match(x, f) @@ -13,7 +13,7 @@ def decode_int(x, f): raise ValueError return (long(m.group(1)), m.end()) -string_filter = re.compile('(0|[1-9][0-9]*):') +string_filter = compile('(0|[1-9][0-9]*):') def decode_string(x, f): m = string_filter.match(x, f)