Re: MemoryError in data conversion

2014-04-15 Thread Gregory Ewing
Mok-Kong Shen wrote: (It means that I have to pickle out the list to a file and read in the content of the file in order to have it as a bytearray etc. etc.) No, you don't -- pickle.dumps() returns the pickled data as a bytes object instead of writing it to a file. -- Greg -- https://mail.pyth

Re: MemoryError in data conversion

2014-04-15 Thread Peter Otten
Gregory Ewing wrote: > Mok-Kong Shen wrote: >> I have yet a question out of curiosity: Why is my 2nd list structure, >> that apparently is too complex for handling by eval and json, seemingly >> not a problem for pickle? > > Pickle is intended for arbitrary data structures, so it > is designed to

Re: MemoryError in data conversion

2014-04-15 Thread Mok-Kong Shen
Am 15.04.2014 01:51, schrieb Gregory Ewing: Mok-Kong Shen wrote: I have yet a question out of curiosity: Why is my 2nd list structure, that apparently is too complex for handling by eval and json, seemingly not a problem for pickle? Pickle is intended for arbitrary data structures, so it is de

Re: MemoryError in data conversion

2014-04-14 Thread Gregory Ewing
Mok-Kong Shen wrote: I have yet a question out of curiosity: Why is my 2nd list structure, that apparently is too complex for handling by eval and json, seemingly not a problem for pickle? Pickle is intended for arbitrary data structures, so it is designed to be able to handle deeply-nested and

Re: MemoryError in data conversion

2014-04-14 Thread Mok-Kong Shen
Am 14.04.2014 15:59, schrieb Peter Otten: You could use json, but you may run into the same problem with that, too (only later): import json items = [] for i in range(1000): ... s = json.dumps(items) ... items = [items] ... Traceback (most recent call last): File "", line 2, in

Re: MemoryError in data conversion

2014-04-14 Thread Peter Otten
Mok-Kong Shen wrote: > Am 14.04.2014 09:46, schrieb Peter Otten: > >> You ran into a limitation of the compiler. For us to suggest a workaround >> you'd have to explain why you want to convert the list returned from >> buildhuffmantree() into python source code and back. > > That list gives the

Re: MemoryError in data conversion

2014-04-14 Thread Mok-Kong Shen
Am 14.04.2014 09:46, schrieb Peter Otten: You ran into a limitation of the compiler. For us to suggest a workaround you'd have to explain why you want to convert the list returned from buildhuffmantree() into python source code and back. That list gives the Huffman encoding tree for compressin

Re: MemoryError in data conversion

2014-04-14 Thread Peter Otten
Mok-Kong Shen wrote: > The code attached below produces in one of the two IMHO similar cases > (excepting the sizes of the lists involved) MemoryError. Could experts > kindly tell why that's so and whether there is any work-around feasible. Here's a simpler way to reproduce the error: >>> import

Re: MemoryError in data conversion

2014-04-13 Thread dieter
Mok-Kong Shen writes: > The code attached below produces in one of the two IMHO similar cases > (excepting the sizes of the lists involved) MemoryError. Could experts > kindly tell why that's so and whether there is any work-around feasible. "MemoryError" means: the Python process wants more mem

MemoryError in data conversion

2014-04-13 Thread Mok-Kong Shen
The code attached below produces in one of the two IMHO similar cases (excepting the sizes of the lists involved) MemoryError. Could experts kindly tell why that's so and whether there is any work-around feasible. Thanks in advances. M. K. Shen -