While this seems to be the case in Python 2.5 (without a built-in json
class), it isn't true in Python 2.7 (from my tests at least):
############
import string, random, profile, json
#import simplejson as json

def randomString(length):
        return ''.join(random.choice(string.ascii_uppercase + string.digits)
for x in range(length))

t = {}
for x in range(500):
        t[randomString(8)] = randomString(12)

profile.run("eval(repr(t))")
profile.run("json.loads(json.dumps(t))")
############

Using the simplejson class resulted in code significantly slower
(15-20x slower). However, using the built-in json class in Python 2.7
resulted in code slightly faster than repr() (3-5x faster).

With the upcoming support for 2.7, I'd suggest keeping json encoding.
It's also more portable "as-is" although it wouldn't be such a hard
task to switch between the two.


On Jul 13, 2:40 pm, Pol <i...@pol-online.net> wrote:
> Very interesting, thanks for sharing.
>
> If you just need a simple dictionary-like storage, why not just repr()
> and eval() - wouldn't that be even faster?
>
> On Jul 13, 8:05 am, someone1 <someo...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I just looked into this myself. Best bet is to use a Text or Blob
> > property to store in a JSON format:
>
> >http://kovshenin.com/archives/pickle-vs-json-which-is-faster/
>
> > I did many tests with 250-500 expando properties and the results were
> > horrendous. From digging around I didn't find a way to disable
> > indexing expando properties, and this made writing them very
> > expensive.
>
> > On Jul 13, 1:35 am, Pol <i...@pol-online.net> wrote:
>
> > > Hi,
>
> > > Regarding expando properties:
>
> > > 1) Can you prevent them from being indexed (I couldn't find anything
> > > about this, but I'd like official confirmation)?
>
> > > 2) What's the practical number of expando properties you shouldn't go
> > > above? If they are all indexed, then surely that can be quite
> > > expensive, so you should stay below 100 or something?
>
> > > 3) If you have to be above the limit defined at #2, what's the best
> > > alternative? Serializing into a blob property, possibly, but what
> > > would be the most optimal serialization format?
>
> > > Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to