From: Chris M. <ch...@hd...> - 2001-08-29 16:39:25
|
Is there a problem with the pickle module in jython2.1a3 (or actually any of the 2.1 versions)? This program: f=open('junkpickle.txt','w') j=[] for i in range(10): j.append(i) pickle.dump(j,f) makes the junkpickle.txt file, but nothing gets dumped to it. The same code works fine with jython 2.0, but doesn't work with 2.1a1 or 2.1a3. Sorry if this is an old problem, but I did a search of the mailing list archives and nothing showed up there, so I thought I'd ask. Thanks, Chris |
From: Robert W. B. <rb...@di...> - 2001-08-29 18:25:28
|
Hello Chris, Probably not pickle, but PyFile. Even without pickle, the following file is empty: open('junk.txt', 'w').write('This is a test') Currently, an explicit close() or flush() is required on the file. e.g. f = open('junkpickle.txt', 'w') pickle.dump(range(10), f) f.close() # or flush() This makes the following usage a bad idea <g> pickle.dump(range(10), open("pickle.txt", "w")) Yes, this was not required in 2.0, but this is the scoop since 2.1a1. Unfortuately, a search on PyFile in the checkins list doesn't return any hits (crummy Geocrawler). However, The diff between the 2.0 and 2.1a1 PyFile is sizable. I don't know if this change in autoflushing is intentional or not. It's worthy of a FAQ entry or a patch depending on the answer to that. -rb On Wed, 29 Aug 2001, Chris Meyers wrote: > Is there a problem with the pickle module in jython2.1a3 (or actually any of the 2.1 versions)? This program: > > f=open('junkpickle.txt','w') > j=[] > for i in range(10): > j.append(i) > pickle.dump(j,f) > > makes the junkpickle.txt file, but nothing gets dumped to it. The same > code works fine with jython 2.0, but doesn't work with 2.1a1 or 2.1a3. > > Sorry if this is an old problem, but I did a search of the mailing list > archives and nothing showed up there, so I thought I'd ask. > > Thanks, > Chris > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > http://lists.sourceforge.net/lists/listinfo/jython-users > |
From: Chris M. <ch...@hd...> - 2001-08-29 20:19:16
|
Thank you very much, that did the trick. Chris On Wed, Aug 29, 2001 at 01:23:56PM -0500, Robert W. Bill wrote: > Hello Chris, > > Probably not pickle, but PyFile. Even without pickle, the following file > is empty: > > open('junk.txt', 'w').write('This is a test') > > Currently, an explicit close() or flush() is required on the file. e.g. > > f = open('junkpickle.txt', 'w') > pickle.dump(range(10), f) > f.close() # or flush() > > This makes the following usage a bad idea <g> > > pickle.dump(range(10), open("pickle.txt", "w")) > > Yes, this was not required in 2.0, but this is the scoop since 2.1a1. > Unfortuately, a search on PyFile in the checkins list doesn't return > any hits (crummy Geocrawler). However, The diff between the 2.0 and 2.1a1 > PyFile is sizable. I don't know if this change in autoflushing is > intentional or not. It's worthy of a FAQ entry or a patch depending on the > answer to that. > > -rb > > On Wed, 29 Aug 2001, Chris Meyers wrote: > > Is there a problem with the pickle module in jython2.1a3 (or actually any of the 2.1 versions)? This program: > > > > f=open('junkpickle.txt','w') > > j=[] > > for i in range(10): > > j.append(i) > > pickle.dump(j,f) > > > > makes the junkpickle.txt file, but nothing gets dumped to it. The same > > code works fine with jython 2.0, but doesn't work with 2.1a1 or 2.1a3. > > > > Sorry if this is an old problem, but I did a search of the mailing list > > archives and nothing showed up there, so I thought I'd ask. > > > > Thanks, > > Chris > > > > _______________________________________________ > > Jython-users mailing list > > Jyt...@li... > > http://lists.sourceforge.net/lists/listinfo/jython-users > > > > > > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > http://lists.sourceforge.net/lists/listinfo/jython-users -- Chris Meyers 7941 Tree Lane Suite 200 Madison WI 53717 |
From: <bc...@wo...> - 2001-09-04 19:21:56
|
[Robert W. Bill] >Hello Chris, > >Probably not pickle, but PyFile. Even without pickle, the following file >is empty: > >open('junk.txt', 'w').write('This is a test') > >Currently, an explicit close() or flush() is required on the file. e.g. > >f = open('junkpickle.txt', 'w') >pickle.dump(range(10), f) >f.close() # or flush() > >This makes the following usage a bad idea <g> > >pickle.dump(range(10), open("pickle.txt", "w")) > >Yes, this was not required in 2.0, but this is the scoop since 2.1a1. >Unfortuately, a search on PyFile in the checkins list doesn't return >any hits (crummy Geocrawler). However, The diff between the 2.0 and 2.1a1 >PyFile is sizable. I don't know if this change in autoflushing is >intentional or not. It is not intentional, but a result of the buffering (which give us a sizable performance boost, especially for pickle) and the fact that PyFiles isn't closed when exiting. >It's worthy of a FAQ entry or a patch depending on the >answer to that. Probably both, because I don't think we can fix this problem for all versions of java. regards, finn |
From: Robert W. B. <rb...@di...> - 2001-09-04 21:30:28
|
On Tue, 4 Sep 2001, Finn Bock wrote: > [Robert W. Bill] > ><snip> > >I don't know if this change in autoflushing is intentional or not. > > It is not intentional, but a result of the buffering (which give us a > sizable performance boost, especially for pickle) and the fact that > PyFiles isn't closed when exiting. > > >It's worthy of a FAQ entry or a patch depending on the > >answer to that. > > Probably both, because I don't think we can fix this problem for all > versions of java. FAQ entry #3.8 added. If only the patch was as easy <g> -rb |