Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'json': 0.07; 'received:verizon.net': 0.07; 'terry': 0.07; 'python': 0.08; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'api': 0.09; ';-)': 0.12; 'am,': 0.12; 'algorithm': 0.13; 'protocol': 0.15; 'reedy': 0.16; 'wrote:': 0.16; '>>>': 0.18; 'jan': 0.19; 'header :In-Reply-To:1': 0.22; 'breaks': 0.23; 'documented': 0.23; 'objects,': 0.23; 'priority': 0.23; 'function': 0.27; 'classes': 0.28; '(and': 0.29; '---': 0.29; 'elsewhere': 0.30; 'fork': 0.30; 'protocol.': 0.30; 'protocols': 0.30; 'class': 0.30; 'list': 0.32; 'cases': 0.32; 'objects': 0.32; 'implement': 0.32; 'to:addr :python-list': 0.33; 'instead': 0.33; 'rules': 0.34; 'header:User- Agent:1': 0.34; 'curious': 0.34; 'like:': 0.34; 'header:X -Complaints-To:1': 0.35; 'object': 0.35; 'url:python': 0.36; 'received:org': 0.38; 'url:org': 0.38; 'subject:: ': 0.39; 'url:docs': 0.39; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'case': 0.39; 'where': 0.40; 'custom': 0.61; 'free': 0.63; 'plus': 0.65; 'benefit': 0.66; 'special': 0.67; '3.3': 0.84; 'url:datamodel': 0.84; 'url:reference': 0.84; 'summarized': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Forking simplejson Date: Wed, 26 Oct 2011 15:29:09 -0400 References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Gmane-NNTP-Posting-Host: pool-74-109-121-73.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20110812 Thunderbird/6.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 42 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1319657367 news.xs4all.nl 6915 [2001:888:2000:d::a6]:52348 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:15010 On 10/26/2011 5:14 AM, Amirouche Boubekki wrote: > H=C3=A9llo, > > I would like to fork simplejson [1] and implement serialization rules > based on protocols instead of types [2], plus special cases for protoco= l > free objects, that breaks compatibility. The benefit will be a better > API for json serialization of custom classes and in the case of iterabl= e > it will avoid a calls like: > > >>> simplejson.dumps(list(my_iterable)) > > The serialization of custom objects is documented in the class instead > of the ``default`` function of current simplejson implementation [3]. > > The encoding algorithm works with a priority list that is summarized in= > the next table: > > +-------------------+---------------+ > | Python protocol | JSON | > | or special case | | > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ > | (=C3=B8) __json__ | see (=C3=B8) | > +-------------------+---------------| > | map | object | I am curious what you mean by the 'map' protocol. > Where are documented the different protocols implemented by Python=20 objects ? Ref 3.3 special method names (and elsewhere ;-) http://docs.python.org/py3k/reference/datamodel.html#special-method-names= --- Terry Jan Reedy