Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'diff': 0.05; 'ignored': 0.05; 'json': 0.07; 'dict': 0.09; 'incorrect': 0.09; 'objects.': 0.09; 'repr': 0.09; 'separately': 0.09; 'unexpected': 0.09; 'cc:addr:python-list': 0.10; 'read.': 0.13; 'wed,': 0.15; 'output': 0.15; 'weird': 0.15; '4:25': 0.16; '4:39': 0.16; 'compares': 0.16; 'encoders': 0.16; 'json,': 0.16; 'principled': 0.16; 'reedy': 0.16; 'subject:make': 0.16; 'two,': 0.16; "{'a':": 0.16; 'wrote:': 0.16; 'string': 0.17; 'comparing': 0.18; '(in': 0.18; 'examples': 0.18; 'tests': 0.18; '>>>': 0.20; 'compare': 0.20; 'cc:2**0': 0.21; 'cc:addr:python.org': 0.21; 'class,': 0.22; 'produces': 0.22; 'subject:request': 0.22; 'text,': 0.22; '2015': 0.23; '(like': 0.23; 'bigger': 0.23; 'header:In-Reply-To:1': 0.24; 'written': 0.24; 'sort': 0.25; 'moved': 0.27; 'message- id:@mail.gmail.com': 0.28; 'subject:/': 0.29; 'buffers': 0.29; 'clever': 0.29; 'inspect': 0.29; 'terry': 0.29; 'up:': 0.29; 'objects': 0.29; 'code': 0.31; "can't": 0.32; 'probably': 0.32; 'structure': 0.32; 'though,': 0.32; 'problem': 0.33; 'everyone': 0.34; 'equal': 0.34; 'received:google.com': 0.34; 'useful': 0.35; 'formats': 0.35; 'protocol': 0.35; 'strongly': 0.35; 'but': 0.36; 'being': 0.36; 'text': 0.36; 'except': 0.36; 'possible.': 0.36; 'there': 0.36; 'data.': 0.36; 'loaded': 0.36; 'two': 0.37; 'should': 0.37; 'subject:: ': 0.37; 'difference': 0.38; 'rather': 0.38; 'goes': 0.39; 'pm,': 0.39; 'test': 0.39; 'easily': 0.39; 'data': 0.40; 'where': 0.40; 'some': 0.40; "you've": 0.61; 'results.': 0.63; 'different': 0.64; 'other.': 0.64; 'between': 0.65; 'subject:read': 0.84; 'subject:write': 0.84; 'overall,': 0.93; 'regard,': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=/zoTghtP620640K5t5AvWW8TITFHdHKvzGh1Parc6Lk=; b=n0Wd8zZe6CEuDtpAsddOA1YbzK2t2co9u4LR2a+SPR0CqZ1F/ksn3yiqx2jqhb9vYS XfpQIclJcYZm4xuyoiljIZQ2GoE/z6nCBQGvmb3355klmW6NQHaGaIPPctXF+eRhhNgl AQWkQkt74F4u2NNM5k5QVqNeztj+RbasiAZiQd4Ru30FVOwtVwsR4XLjwxaz2wi5/B81 4dcmXSkiE8LG81xTKfKk4MsfRJeOYpnKGdoE4XLy7RL+8pXTy4szyPdfScekS/ZBvXP0 /WSF2rYXGZRZy6i/t2tquC0Wbah2HZ6Y2/iVyh/To4E1+RdFIJk3dl0mIA2oH+1e2jaS eipg== X-Received: by 10.180.100.194 with SMTP id fa2mr23947108wib.8.1433980127598; Wed, 10 Jun 2015 16:48:47 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <55778208$0$2899$e4fe514c@news2.news.xs4all.nl> <5577b46d$0$12975$c3e8da3$5496439d@news.astraweb.com> <5578053a$0$11102$c3e8da3@news.astraweb.com> From: Devin Jeanpierre Date: Wed, 10 Jun 2015 16:48:07 -0700 Subject: Re: enhancement request: make py3 read/write py2 pickle format To: Terry Reedy Cc: "comp.lang.python" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1433980134 news.xs4all.nl 2957 [2001:888:2000:d::a6]:48186 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:92433 On Wed, Jun 10, 2015 at 4:39 PM, Devin Jeanpierre wrote: > On Wed, Jun 10, 2015 at 4:25 PM, Terry Reedy wrote: >> On 6/10/2015 6:10 PM, Devin Jeanpierre wrote: >> >>> The problem is that there are two different ways repr might write out >>> a dict equal to {'a': 1, 'b': 2}. This can make tests brittle >> >> >> Not if one compares objects rather than string representations of objects. >> I am strongly of the view that code and tests should be written to directly >> compare objects as much as possible. > > For serialization formats that always output the same string for the > same data (like text format protos), there is no practical difference > between the two, except that if you're comparing text, you can easily > supply a diff to update one to match the other. Ugh, there's also the fiddly difference between what goes in and what you read. A serialized data structure might contain lots of data that is ignored by the deserializer (in protobuf), or it might contain data which can't be loaded by the deserializer or produces weird / incorrect results. Being able to inspect and test the serialized data separately from the deserialized data is useful in that regard, so that you know where the failure lies, but it's sort of fuzzy. Some examples of where this crops up: pickles after you've moved a class, JSON encoders that try to be clever and output invalid JSON, protocol buffers with unexpected fields. Overall, though, the diff thing is probably the bigger reason everyone wants to do this sort of thing with serialized data. If you do it right and are principled about it, I don't see a problem with it. -- Devin