Message201293
just to mention that map() (i.e. the non parallel version) works:
import lzma
from functools import partial
import multiprocessing
def run_lzma(data,c):
return c.compress(data)
def split_len(seq, length):
return [str.encode(seq[i:i+length]) for i in range(0, len(seq), length)]
sequence='AAAAAJKDDDDDDDDDDDDDDDDDDDDDDDDDDDDGJFKSHFKLHALWEHAIHWEOIAH IOAHIOWEHIOHEIOFEAFEASFEAFWEWWWWWWWWWWWWWWWWWWWWWWWWWWWWWEWFQWEWQWQGEWQFEWFDWEWEGEFGWEG'
threads=3
blocksize = int(round(len(sequence)/threads))
strings = split_len(sequence, blocksize)
#map works
lzc = lzma.LZMACompressor()
out = list(map(lzc.compress,strings))
out_flush = lzc.flush()
result = b"".join(out + [out_flush])
lzma.compress(str.encode(sequence))
lzma.compress(str.encode(sequence)) == result
True
# map with the use of partial function works as well
lzc = lzma.LZMACompressor()
lzc_partial = partial(run_lzma,c=lzc)
out = list(map(lzc_partial,strings))
out_flush = lzc.flush()
result = b"".join(out + [out_flush])
lzma.compress(str.encode(sequence)) == result |
|
Date |
User |
Action |
Args |
2013-10-25 21:04:59 | cantor | set | recipients:
+ cantor, pitrou, nadeem.vawda |
2013-10-25 21:04:59 | cantor | set | messageid: <1382735099.12.0.33397571711.issue19395@psf.upfronthosting.co.za> |
2013-10-25 21:04:59 | cantor | link | issue19395 messages |
2013-10-25 21:04:59 | cantor | create | |
|