if it's as bad as 6 to 8 seconds, have you looked at creating a list of string for the property names? i know its more maintenance overhead, but might be worth the tradeoff..
ex: class SerializableModel(object): serializable = [] def to_json(self): result = [] for x in self.serializable: result.append(self.__dict__[x]) ## append values from self.properties().items() class A(db.Model, SerializableModel): serializable = ['user_keys'] _user_keys = db.StringListProperty(default=[], indexed=False) @property def user_keys(self): return [db.Key(x) for x in self._user_keys] @property def user_keys_count(self): """not in serializable list""" return len(self._user_keys) On Jan 10, 9:05 am, Andreas <a.schmi...@gmail.com> wrote: > hi, > > im using more or less this > (http://www.awebcoder.com/post/91001/extended-jsonify-function-for-app...) > jsonify function to serialize whatever object i pass into the jsonify() > function and i have to say it does all i need and works pretty good. > the only downside i see right now is the speed. if i try to serialize 50 > db.Model objects with around 10 properties each in production it takes 6-8 > seconds which is not exactly what i would expect. > > is there a way to make this part of code more performant? > for property in dir(obj): > if property[0] != '_': > try: > value = obj.__getattribute__(property) > valueClass = str(value.__class__) > if not(('function' in valueClass) or ('built' in valueClass) > or ('method' in valueClass)): > value = dumps(value) > if value != None: > properties[property] = value > else: > properties[property] = "" > except: continue > if len(properties) == 0: > return str(obj) > else: > return properties > > i know i could use obj.properties().items() to loop over the properties but i > would not be able to serialize properties which are @property functions > because those don't get listed in the obj.properties() list. > > right now im caching the results so im gaining speed because i get the result > from memcache but when i flush the cache or the memcached result is not > available it takes too much until the result is ready. > > thx -- 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.