Re: cPickle.load vs. file.read+cPickle.loads on large binary files

2015-11-18 Thread andrea . gavana
Hi, On Wednesday, November 18, 2015 at 10:00:43 AM UTC+1, Nagy László Zsolt wrote: > > Perhaps there is a size threshold? You could experiment with different > > block > > sizes in the following f.read() replacement: > > > > def read_chunked(f, size=2**20): > > read = functools.partial(f.rea

Re: cPickle.load vs. file.read+cPickle.loads on large binary files

2015-11-18 Thread Nagy László Zsolt
> Perhaps there is a size threshold? You could experiment with different block > sizes in the following f.read() replacement: > > def read_chunked(f, size=2**20): > read = functools.partial(f.read, size) > return "".join(iter(read, "")) > Under win32 platform, my experience is that the fa

Re: cPickle.load vs. file.read+cPickle.loads on large binary files

2015-11-17 Thread Peter Otten
andrea.gav...@gmail.com wrote: >> > I am puzzled with no end... Might there be something funny with my C >> > libraries that use fread? I'm just shooting in the dark. I have a >> > standard Python installation on Windows, nothing fancy :-( >> >> Perhaps there is a size threshold? You could experi

Re: cPickle.load vs. file.read+cPickle.loads on large binary files

2015-11-17 Thread andrea . gavana
Hi Peter, On Tuesday, November 17, 2015 at 4:57:57 PM UTC+1, Peter Otten wrote: > Andrea Gavana wrote: > > > Hi Chris, > > > > On Tuesday, November 17, 2015 at 4:20:34 PM UTC+1, Chris Angelico wrote: > >> On Wed, Nov 18, 2015 at 1:20 AM, Andrea Gavana wrote: > >> > Thank you for your answer. I

Re: cPickle.load vs. file.read+cPickle.loads on large binary files

2015-11-17 Thread Peter Otten
andrea.gav...@gmail.com wrote: > Hi Chris, > > On Tuesday, November 17, 2015 at 4:20:34 PM UTC+1, Chris Angelico wrote: >> On Wed, Nov 18, 2015 at 1:20 AM, Andrea Gavana wrote: >> > Thank you for your answer. I do get similar timings when I swap the two >> > functions, and specifically still 15

Re: cPickle.load vs. file.read+cPickle.loads on large binary files

2015-11-17 Thread andrea . gavana
Hi Chris, On Tuesday, November 17, 2015 at 4:20:34 PM UTC+1, Chris Angelico wrote: > On Wed, Nov 18, 2015 at 1:20 AM, Andrea Gavana wrote: > > Thank you for your answer. I do get similar timings when I swap the two > > functions, and specifically still 15 seconds to read the file via > > file.r

Re: cPickle.load vs. file.read+cPickle.loads on large binary files

2015-11-17 Thread Chris Angelico
On Wed, Nov 18, 2015 at 1:20 AM, wrote: > Thank you for your answer. I do get similar timings when I swap the two > functions, and specifically still 15 seconds to read the file via file.read() > and 2.4 seconds (more or less as before) via cPickle.load(fid). > > I thought that the order of ope

Re: cPickle.load vs. file.read+cPickle.loads on large binary files

2015-11-17 Thread andrea . gavana
Hi Peter, On Tuesday, November 17, 2015 at 3:14:57 PM UTC+1, Peter Otten wrote: > Andrea Gavana wrote: > > > Hello List, > > > > I am working with relatively humongous binary files (created via > > cPickle), and I stumbled across some unexpected (for me) performance > > difference

Re: cPickle.load vs. file.read+cPickle.loads on large binary files

2015-11-17 Thread Peter Otten
andrea.gav...@gmail.com wrote: > Hello List, > > I am working with relatively humongous binary files (created via > cPickle), and I stumbled across some unexpected (for me) performance > differences between two approaches I use to load those files: > > 1. Simply use cPickle.load(f

cPickle.load vs. file.read+cPickle.loads on large binary files

2015-11-17 Thread andrea . gavana
Hello List, I am working with relatively humongous binary files (created via cPickle), and I stumbled across some unexpected (for me) performance differences between two approaches I use to load those files: 1. Simply use cPickle.load(fid) 2. Read the file as binary using file.read() and