summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/_sources/index.txt16
-rw-r--r--docs/index.html18
-rw-r--r--docs/searchindex.js2
-rw-r--r--index.rst16
4 files changed, 49 insertions, 3 deletions
diff --git a/docs/_sources/index.txt b/docs/_sources/index.txt
index 9961f96..b4ed26e 100644
--- a/docs/_sources/index.txt
+++ b/docs/_sources/index.txt
@@ -199,6 +199,11 @@ Basic Usage
to a :class:`unicode` object and passed to :func:`loads`. The default
setting of ``'utf-8'`` is fastest and should be using whenever possible.
+ If *fp.read()* returns :class:`str` then decoded JSON strings that contain
+ only ASCII characters may be parsed as :class:`str` for performance and
+ memory reasons. If your code expects only :class:`unicode` the appropriate
+ solution is to wrap fp with a reader as demonstrated above.
+
*object_hook* is an optional function that will be called with the result of
any object literal decode (a :class:`dict`). The return value of
*object_hook* will be used instead of the :class:`dict`. This feature can be used
@@ -252,6 +257,11 @@ Basic Usage
specified. Encodings that are not ASCII based (such as UCS-2) are not
allowed and should be decoded to :class:`unicode` first.
+ If *s* is a :class:`str` then decoded JSON strings that contain
+ only ASCII characters may be parsed as :class:`str` for performance and
+ memory reasons. If your code expects only :class:`unicode` the appropriate
+ solution is decode *s* to :class:`unicode` prior to calling loads.
+
The other arguments have the same meaning as in :func:`load`.
@@ -334,6 +344,12 @@ Encoders and decoders
Return the Python representation of *s* (a :class:`str` or
:class:`unicode` instance containing a JSON document)
+ If *s* is a :class:`str` then decoded JSON strings that contain
+ only ASCII characters may be parsed as :class:`str` for performance and
+ memory reasons. If your code expects only :class:`unicode` the
+ appropriate solution is decode *s* to :class:`unicode` prior to calling
+ decode.
+
.. method:: raw_decode(s)
Decode a JSON document from *s* (a :class:`str` or :class:`unicode`
diff --git a/docs/index.html b/docs/index.html
index a6fb29a..d6cbec1 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -215,6 +215,10 @@ Encodings that are not ASCII based (such as UCS-2) are not allowed, and
should be wrapped with <tt class="docutils literal"><span class="pre">codecs.getreader(fp)(encoding)</span></tt>, or simply decoded
to a <tt class="xref docutils literal"><span class="pre">unicode</span></tt> object and passed to <a title="simplejson.loads" class="reference internal" href="#simplejson.loads"><tt class="xref docutils literal"><span class="pre">loads()</span></tt></a>. The default
setting of <tt class="docutils literal"><span class="pre">'utf-8'</span></tt> is fastest and should be using whenever possible.</p>
+<p>If <em>fp.read()</em> returns <tt class="xref docutils literal"><span class="pre">str</span></tt> then decoded JSON strings that contain
+only ASCII characters may be parsed as <tt class="xref docutils literal"><span class="pre">str</span></tt> for performance and
+memory reasons. If your code expects only <tt class="xref docutils literal"><span class="pre">unicode</span></tt> the appropriate
+solution is to wrap fp with a reader as demonstrated above.</p>
<p><em>object_hook</em> is an optional function that will be called with the result of
any object literal decode (a <tt class="xref docutils literal"><span class="pre">dict</span></tt>). The return value of
<em>object_hook</em> will be used instead of the <tt class="xref docutils literal"><span class="pre">dict</span></tt>. This feature can be used
@@ -263,6 +267,10 @@ document) to a Python object.</p>
other than UTF-8 (e.g. latin-1), then an appropriate <em>encoding</em> name must be
specified. Encodings that are not ASCII based (such as UCS-2) are not
allowed and should be decoded to <tt class="xref docutils literal"><span class="pre">unicode</span></tt> first.</p>
+<p>If <em>s</em> is a <tt class="xref docutils literal"><span class="pre">str</span></tt> then decoded JSON strings that contain
+only ASCII characters may be parsed as <tt class="xref docutils literal"><span class="pre">str</span></tt> for performance and
+memory reasons. If your code expects only <tt class="xref docutils literal"><span class="pre">unicode</span></tt> the appropriate
+solution is decode <em>s</em> to <tt class="xref docutils literal"><span class="pre">unicode</span></tt> prior to calling loads.</p>
<p>The other arguments have the same meaning as in <a title="simplejson.load" class="reference internal" href="#simplejson.load"><tt class="xref docutils literal"><span class="pre">load()</span></tt></a>.</p>
</dd></dl>
@@ -349,8 +357,14 @@ characters will be allowed in strings.</p>
<dl class="method">
<dt id="simplejson.JSONDecoder.decode">
<!--[simplejson.JSONDecoder.decode]--><tt class="descname">decode</tt><big>(</big><em>s</em><big>)</big><a class="headerlink" href="#simplejson.JSONDecoder.decode" title="Permalink to this definition">ΒΆ</a></dt>
-<dd>Return the Python representation of <em>s</em> (a <tt class="xref docutils literal"><span class="pre">str</span></tt> or
-<tt class="xref docutils literal"><span class="pre">unicode</span></tt> instance containing a JSON document)</dd></dl>
+<dd><p>Return the Python representation of <em>s</em> (a <tt class="xref docutils literal"><span class="pre">str</span></tt> or
+<tt class="xref docutils literal"><span class="pre">unicode</span></tt> instance containing a JSON document)</p>
+<p>If <em>s</em> is a <tt class="xref docutils literal"><span class="pre">str</span></tt> then decoded JSON strings that contain
+only ASCII characters may be parsed as <tt class="xref docutils literal"><span class="pre">str</span></tt> for performance and
+memory reasons. If your code expects only <tt class="xref docutils literal"><span class="pre">unicode</span></tt> the
+appropriate solution is decode <em>s</em> to <tt class="xref docutils literal"><span class="pre">unicode</span></tt> prior to calling
+decode.</p>
+</dd></dl>
<dl class="method">
<dt id="simplejson.JSONDecoder.raw_decode">
diff --git a/docs/searchindex.js b/docs/searchindex.js
index 504ce20..d2e081b 100644
--- a/docs/searchindex.js
+++ b/docs/searchindex.js
@@ -1 +1 @@
-Search.setIndex({desctypes:{"0":"class","1":"method","2":"function"},terms:{represent:0,all:0,skip:0,interchang:0,signific:0,follow:0,compact:0,typeerror:0,decim:0,rstrip:0,sens:0,spec:0,isinst:0,liter:0,everi:0,string:0,raw_decod:0,fals:0,jsonencod:0,level:0,list:0,iter:0,"try":0,item:0,prevent:0,pass:0,compat:0,index:0,compar:0,current:0,version:0,"new":0,method:0,item_separ:0,elimin:0,valu:0,num_str:0,convert:0,prior:0,chang:0,overrid:0,modul:0,api:0,coercion:0,select:0,highli:0,from:0,would:0,call:0,recommend:0,type:0,more:0,sort:0,unescap:0,must:0,none:0,join:0,bigobject:0,work:0,skipkei:0,wors:0,can:0,def:0,control:0,stream:0,accept:0,object_pairs_hook:0,serial:0,alwai:0,end:0,newlin:0,anoth:0,write:0,instead:0,simpl:0,circular:0,recogn:0,earlier:0,mai:0,data:0,attempt:0,correspond:0,marshal:0,caus:0,jsonencoderforhtml:0,maintain:0,allow:0,order:0,becaus:0,hierarchi:0,better:0,yaml:0,html:0,them:0,"return":0,thei:0,python:0,safe:0,dai:0,allow_nan:0,jsondecod:0,superset:0,name:0,anyth:0,edit:0,separ:0,getvalu:0,each:0,unicod:0,mean:0,subset:0,chunk:0,wrap:0,expect:0,special:0,out:0,"3rd":0,space:0,content:0,print:0,after:0,infin:0,standard:0,base:0,dictionari:0,element:0,org:0,basi:0,indent:0,could:0,place:0,outsid:0,regress:0,first:0,rang:0,arrai:0,number:0,echo:0,unlik:0,prioriti:0,given:0,reli:0,shell:0,option:0,tool:0,specifi:0,pars:0,than:0,keyword:0,whenev:0,provid:0,structur:0,charact:0,str:0,pre:0,encode_complex:0,ani:0,have:0,"null":0,equival:0,self:0,note:0,also:0,exampl:0,take:0,which:0,even:0,begin:0,unless:0,normal:0,object:0,most:0,getread:0,pair:0,"class":0,doe:0,determin:0,serializ:0,speedup:0,syntax:0,find:0,onli:0,explicitli:0,parse_float:0,pretti:0,should:0,iterencod:0,dict:0,object_hook:0,get:0,familiar:0,stop:0,repr:0,fastest:0,key_separ:0,bar:0,baz:0,yield:0,contain:0,where:0,valid:0,set:0,dump:0,frame:0,datatyp:0,result:0,best:0,subject:0,infinit:0,kei:0,dict_separ:0,written:0,"import":0,latin:0,extend:0,parse_const:0,javascript:0,extens:0,embed:0,addit:0,delimit:0,instanc:0,mani:0,ecma:0,load:0,simpli:0,rpc:0,getwrit:0,"__complex__":0,json:0,much:0,interpret:0,basic:0,valueerror:0,imag:0,argument:0,understand:0,input:0,sort_kei:0,those:0,"case":0,x08ar:0,properti:0,defin:0,behavior:0,error:0,ordereddict:0,advantag:0,kwarg:0,lightweight:0,incom:0,ascii:0,u1234:0,perform:0,make:0,same:0,member:0,complex:0,decod:0,document:0,http:0,optim:0,nest:0,effect:0,rais:0,user:0,extern:0,implement:0,appropri:0,well:0,pickl:0,without:0,thi:0,protocol:0,mysocket:0,rest:0,as_complex:0,parse_int:0,expos:0,hint:0,except:0,codec:0,els:0,real:0,format:0,read:0,recurs:0,insert:0,like:0,specif:0,arbitrari:0,docutil:0,whitespac:0,integ:0,collect:0,output:0,encount:0,some:0,check_circular:0,superclass:0,guarante:0,librari:0,subclass:0,when:0,leav:0,foo:0,refer:0,usag:0,dct:0,obj:0,column:0,splitlin:0,constructor:0,produc:0,"float":0,encod:0,ensur:0,span:0,complianc:0,support:0,transform:0,"long":0,custom:0,avail:0,strict:0,compliant:0,overflowerror:0,"function":0,simplejson:0,tupl:0,translat:0,line:0,"true":0,notat:0,utf:0,consist:0,possibl:0,"default":0,otherwis:0,ensure_ascii:0,featur:0,"int":0,dure:0,parser:0,"char":0,extran:0,file:0,inf:0,check:0,nan:0,invalid:0,other:0,bool:0,rememb:0,test:0,you:0,deseri:0,repeat:0,stringio:0,rule:0,escap:0,backward:0},titles:["<tt class=\"docutils literal\"><span class=\"pre\">simplejson</span></tt> &#8212; JSON encoder and decoder"],modules:{simplejson:0},descrefs:{"simplejson.JSONEncoder":{"default":[0,1],encode:[0,1],iterencode:[0,1]},"simplejson.JSONDecoder":{decode:[0,1],raw_decode:[0,1]},simplejson:{load:[0,2],JSONEncoder:[0,0],dump:[0,2],JSONDecoder:[0,0],dumps:[0,2],JSONEncoderForHTML:[0,0],loads:[0,2]}},filenames:["index"]}) \ No newline at end of file
+Search.setIndex({desctypes:{"0":"class","1":"method","2":"function"},terms:{represent:0,all:0,code:0,skip:0,interchang:0,signific:0,follow:0,compact:0,typeerror:0,decim:0,rstrip:0,sens:0,spec:0,isinst:0,liter:0,everi:0,string:0,raw_decod:0,fals:0,jsonencod:0,level:0,list:0,iter:0,"try":0,item:0,prevent:0,pass:0,compat:0,index:0,compar:0,current:0,version:0,"new":0,method:0,item_separ:0,elimin:0,behavior:0,valu:0,num_str:0,convert:0,prior:0,chang:0,overrid:0,modul:0,api:0,coercion:0,select:0,highli:0,from:0,would:0,memori:0,call:0,recommend:0,type:0,more:0,sort:0,unescap:0,must:0,none:0,join:0,bigobject:0,work:0,skipkei:0,wors:0,can:0,def:0,control:0,stream:0,accept:0,object_pairs_hook:0,serial:0,alwai:0,end:0,newlin:0,anoth:0,write:0,instead:0,simpl:0,circular:0,recogn:0,after:0,mai:0,data:0,demonstr:0,attempt:0,correspond:0,marshal:0,caus:0,jsonencoderforhtml:0,maintain:0,allow:0,order:0,becaus:0,hierarchi:0,better:0,yaml:0,html:0,them:0,"return":0,thei:0,python:0,safe:0,dai:0,allow_nan:0,jsondecod:0,superset:0,name:0,anyth:0,edit:0,separ:0,getvalu:0,each:0,unicod:0,mean:0,subset:0,chunk:0,wrap:0,expect:0,special:0,out:0,"3rd":0,space:0,content:0,reader:0,print:0,earlier:0,infin:0,standard:0,reason:0,base:0,dictionari:0,element:0,org:0,basi:0,indent:0,could:0,place:0,outsid:0,regress:0,first:0,rang:0,arrai:0,number:0,echo:0,unlik:0,prioriti:0,given:0,reli:0,shell:0,option:0,tool:0,specifi:0,pars:0,than:0,keyword:0,whenev:0,provid:0,structur:0,charact:0,str:0,other:0,pre:0,encode_complex:0,argument:0,have:0,"null":0,equival:0,self:0,note:0,also:0,without:0,take:0,which:0,even:0,begin:0,unless:0,normal:0,object:0,most:0,getread:0,pair:0,"class":0,nan:0,doe:0,determin:0,serializ:0,speedup:0,syntax:0,find:0,onli:0,explicitli:0,parse_float:0,pretti:0,solut:0,should:0,iterencod:0,dict:0,object_hook:0,get:0,familiar:0,stop:0,repr:0,fastest:0,key_separ:0,bar:0,baz:0,yield:0,contain:0,where:0,set:0,dump:0,frame:0,datatyp:0,result:0,best:0,subject:0,infinit:0,kei:0,dict_separ:0,written:0,"import":0,latin:0,extend:0,parse_const:0,javascript:0,extens:0,ensure_ascii:0,addit:0,delimit:0,instanc:0,mani:0,ecma:0,load:0,simpli:0,rpc:0,getwrit:0,"__complex__":0,json:0,much:0,interpret:0,basic:0,valueerror:0,imag:0,ani:0,understand:0,input:0,sort_kei:0,those:0,"case":0,x08ar:0,properti:0,defin:0,abov:0,error:0,ordereddict:0,advantag:0,kwarg:0,lightweight:0,incom:0,ascii:0,u1234:0,perform:0,make:0,same:0,member:0,complex:0,decod:0,document:0,http:0,optim:0,nest:0,effect:0,rais:0,user:0,extern:0,implement:0,appropri:0,well:0,pickl:0,exampl:0,thi:0,protocol:0,mysocket:0,rest:0,as_complex:0,parse_int:0,expos:0,hint:0,except:0,codec:0,els:0,real:0,format:0,read:0,recurs:0,insert:0,like:0,specif:0,arbitrari:0,docutil:0,whitespac:0,integ:0,collect:0,output:0,encount:0,some:0,check_circular:0,superclass:0,guarante:0,librari:0,subclass:0,leav:0,foo:0,refer:0,usag:0,dct:0,obj:0,column:0,splitlin:0,constructor:0,produc:0,"float":0,encod:0,ensur:0,your:0,span:0,complianc:0,support:0,transform:0,"long":0,custom:0,avail:0,strict:0,compliant:0,overflowerror:0,"function":0,simplejson:0,tupl:0,translat:0,line:0,"true":0,notat:0,utf:0,consist:0,possibl:0,"default":0,otherwis:0,embed:0,featur:0,"int":0,dure:0,parser:0,"char":0,rule:0,file:0,inf:0,check:0,when:0,invalid:0,valid:0,bool:0,rememb:0,test:0,you:0,deseri:0,repeat:0,stringio:0,extran:0,escap:0,backward:0},titles:["<tt class=\"docutils literal\"><span class=\"pre\">simplejson</span></tt> &#8212; JSON encoder and decoder"],modules:{simplejson:0},descrefs:{"simplejson.JSONEncoder":{"default":[0,1],encode:[0,1],iterencode:[0,1]},"simplejson.JSONDecoder":{decode:[0,1],raw_decode:[0,1]},simplejson:{load:[0,2],JSONEncoder:[0,0],dump:[0,2],JSONDecoder:[0,0],dumps:[0,2],JSONEncoderForHTML:[0,0],loads:[0,2]}},filenames:["index"]}) \ No newline at end of file
diff --git a/index.rst b/index.rst
index 9961f96..b4ed26e 100644
--- a/index.rst
+++ b/index.rst
@@ -199,6 +199,11 @@ Basic Usage
to a :class:`unicode` object and passed to :func:`loads`. The default
setting of ``'utf-8'`` is fastest and should be using whenever possible.
+ If *fp.read()* returns :class:`str` then decoded JSON strings that contain
+ only ASCII characters may be parsed as :class:`str` for performance and
+ memory reasons. If your code expects only :class:`unicode` the appropriate
+ solution is to wrap fp with a reader as demonstrated above.
+
*object_hook* is an optional function that will be called with the result of
any object literal decode (a :class:`dict`). The return value of
*object_hook* will be used instead of the :class:`dict`. This feature can be used
@@ -252,6 +257,11 @@ Basic Usage
specified. Encodings that are not ASCII based (such as UCS-2) are not
allowed and should be decoded to :class:`unicode` first.
+ If *s* is a :class:`str` then decoded JSON strings that contain
+ only ASCII characters may be parsed as :class:`str` for performance and
+ memory reasons. If your code expects only :class:`unicode` the appropriate
+ solution is decode *s* to :class:`unicode` prior to calling loads.
+
The other arguments have the same meaning as in :func:`load`.
@@ -334,6 +344,12 @@ Encoders and decoders
Return the Python representation of *s* (a :class:`str` or
:class:`unicode` instance containing a JSON document)
+ If *s* is a :class:`str` then decoded JSON strings that contain
+ only ASCII characters may be parsed as :class:`str` for performance and
+ memory reasons. If your code expects only :class:`unicode` the
+ appropriate solution is decode *s* to :class:`unicode` prior to calling
+ decode.
+
.. method:: raw_decode(s)
Decode a JSON document from *s* (a :class:`str` or :class:`unicode`