Re: [Python-Dev] Pickler/Unpickler API clarification

2009-03-07 Thread Greg Ewing
Michael Haggerty wrote: Typically, the purpose of a database is to persist data across program runs. So typically, your suggestion would only help if there were a way to persist the primed Pickler across runs. I don't think you need to be able to pickle picklers. In the case in question, the

Re: [Python-Dev] Pickler/Unpickler API clarification

2009-03-07 Thread Michael Haggerty
Guido van Rossum wrote: > On Sat, Mar 7, 2009 at 8:04 AM, Michael Haggerty wrote: >> Typically, the purpose of a database is to persist data across program >> runs. So typically, your suggestion would only help if there were a way >> to persist the primed Pickler across runs. > > I haven't follo

Re: [Python-Dev] Pickler/Unpickler API clarification

2009-03-07 Thread Guido van Rossum
On Sat, Mar 7, 2009 at 8:04 AM, Michael Haggerty wrote: > Typically, the purpose of a database is to persist data across program > runs.  So typically, your suggestion would only help if there were a way > to persist the primed Pickler across runs. I haven't followed all this, but isn't is at lea

Re: [Python-Dev] Pickler/Unpickler API clarification

2009-03-07 Thread Michael Haggerty
Greg Ewing wrote: > Michael Haggerty wrote: >> A similar effect could *almost* be obtained without accessing the memos >> by saving the pickled primer itself in the database. The unpickler >> would be primed by using it to load the primer before loading the record >> of interest. But AFAIK there

Re: [Python-Dev] Pickler/Unpickler API clarification

2009-03-07 Thread Greg Ewing
Antoine Pitrou wrote: If these strings are not interned, then perhaps they should be. I think this is a different problem. Even if the strings are interned, if you start with a fresh pickler each time, you get a copy of the strings in each pickle. What he wants is to share strings between diff

Re: [Python-Dev] Pickler/Unpickler API clarification

2009-03-07 Thread Greg Ewing
Michael Haggerty wrote: A similar effect could *almost* be obtained without accessing the memos by saving the pickled primer itself in the database. The unpickler would be primed by using it to load the primer before loading the record of interest. But AFAIK there is no way to prime new pickle

Re: [Python-Dev] Pickler/Unpickler API clarification

2009-03-06 Thread Collin Winter
On Fri, Mar 6, 2009 at 10:01 AM, Michael Haggerty wrote: > Antoine Pitrou wrote: >> Le vendredi 06 mars 2009 à 13:44 +0100, Michael Haggerty a écrit : >>> Antoine Pitrou wrote: Michael Haggerty alum.mit.edu> writes: > It is easy to optimize the pickling of instances by giving them >

Re: [Python-Dev] Pickler/Unpickler API clarification

2009-03-06 Thread Michael Haggerty
Antoine Pitrou wrote: > Le vendredi 06 mars 2009 à 13:44 +0100, Michael Haggerty a écrit : >> Antoine Pitrou wrote: >>> Michael Haggerty alum.mit.edu> writes: It is easy to optimize the pickling of instances by giving them __getstate__() and __setstate__() methods. But the pickler still

Re: [Python-Dev] Pickler/Unpickler API clarification

2009-03-06 Thread Michael Haggerty
Antoine Pitrou wrote: > Michael Haggerty alum.mit.edu> writes: >> It is easy to optimize the pickling of instances by giving them >> __getstate__() and __setstate__() methods. But the pickler still >> records the type of each object (essentially, the name of its class) in >> each record. The spa

Re: [Python-Dev] Pickler/Unpickler API clarification

2009-03-06 Thread Antoine Pitrou
Le vendredi 06 mars 2009 à 13:44 +0100, Michael Haggerty a écrit : > Antoine Pitrou wrote: > > Michael Haggerty alum.mit.edu> writes: > >> It is easy to optimize the pickling of instances by giving them > >> __getstate__() and __setstate__() methods. But the pickler still > >> records the type of

Re: [Python-Dev] Pickler/Unpickler API clarification

2009-03-06 Thread Daniel Stutzbach
On Fri, Mar 6, 2009 at 5:45 AM, Antoine Pitrou wrote: > If these strings are not interned, then perhaps they should be. > There is a similar optimization proposal (w/ patch) for attribute names: > http://bugs.python.org/issue5084 > If I understand correctly, that would help with unpickling, but

Re: [Python-Dev] Pickler/Unpickler API clarification

2009-03-06 Thread Antoine Pitrou
Michael Haggerty alum.mit.edu> writes: > > It is easy to optimize the pickling of instances by giving them > __getstate__() and __setstate__() methods. But the pickler still > records the type of each object (essentially, the name of its class) in > each record. The space for these strings cons

Re: [Python-Dev] Pickler/Unpickler API clarification

2009-03-06 Thread Michael Haggerty
Collin Winter wrote: > [...] I've found a few examples of code using the memo attribute ([1], [2], > [3]) [...] As author of [2] (current version here [4]) I can tell you my reason. cvs2svn has to store a vast number of small objects in a database, then read them in random order. I spent a lot of

Re: [Python-Dev] Pickler/Unpickler API clarification

2009-03-05 Thread Greg Ewing
Guido van Rossum wrote: Then it'd be better to have a method clear_memo() on pickle objects. You should have that anyway. I was just suggesting a way of preserving compatibility with old code without exposing all the details of the memo. -- Greg ___

Re: [Python-Dev] Pickler/Unpickler API clarification

2009-03-05 Thread Guido van Rossum
On Thu, Mar 5, 2009 at 1:36 PM, Greg Ewing wrote: > Guido van Rossum wrote: > >> This was a bad idea (*), and I'd be happy to ban it -- but we'd >> probably have to bump the pickle protocol version in order to maintain >> backwards compatibility. > > If you're talking about multiple calls to dump(

Re: [Python-Dev] Pickler/Unpickler API clarification

2009-03-05 Thread Greg Ewing
Guido van Rossum wrote: This was a bad idea (*), and I'd be happy to ban it -- but we'd probably have to bump the pickle protocol version in order to maintain backwards compatibility. If you're talking about multiple calls to dump() on the same pickler, it might be a bad idea for a network con

Re: [Python-Dev] Pickler/Unpickler API clarification

2009-03-05 Thread Greg Ewing
Collin Winter wrote: Reusing the Pickler without clearing the memo will produce pickles that are, as best I can see, invalid I'm not sure what you mean by "reusing the pickler" here, and how it can produce an invalid pickle. I think what the docs mean by it is continuing to pickle objects to

Re: [Python-Dev] Pickler/Unpickler API clarification

2009-03-05 Thread Guido van Rossum
On Thu, Mar 5, 2009 at 12:07 PM, Collin Winter wrote: > I'm working on some performance patches for cPickle, and one of the > bigger wins so far has been replacing the Pickler's memo dict with a > custom hashtable (and hence removing memo's getters and setters). In > looking over this, Jeffrey Yas

[Python-Dev] Pickler/Unpickler API clarification

2009-03-05 Thread Collin Winter
I'm working on some performance patches for cPickle, and one of the bigger wins so far has been replacing the Pickler's memo dict with a custom hashtable (and hence removing memo's getters and setters). In looking over this, Jeffrey Yasskin commented that this would break anyone who was accessing t