I use a custom ArrayProperty:

#----------------------------------------------------------------------
# A lean integer list property
# See https://developers.google.com/appengine/docs/python/ndb/subclassprop
# ArrayProperty
import logging
class ArrayProperty(ndb.BlobProperty):
def __init__(self, typecode, **kwargs):
super(ArrayProperty, self).__init__(**kwargs)
self.typecode=typecode
def _validate(self, value):
if not isinstance(value, array.array) or value.typecode!=self.typecode:
raise TypeError('Property %s must be an array instance with typecode %s 
(instead of %s)'%(self._name, self.typecode, type(value)))
def _to_base_type(self, value):
return value.tostring()
def _from_base_type(self, value):
return array.array(self.typecode, value)

Cheers!
Greg.

On Thursday, 6 March 2014 21:50:56 UTC+13, Pertti Kellomäki wrote:
>
> I need to store lists of smallish integers. The lists consist of a few 
> tens of integers, and the integers are in the triple digit range.
>
> I could obviously use IntegerProperty(repeated=True), but since the lists 
> are basically only used at client side, this feels a bit overkill. There is 
> no need to search or index the lists.
>
> What would be the most efficient way to store these lists? I'm thinking of 
> simply storing them as json strings, but is there something else that I 
> could use?
> -- 
> Pertti Kellomäki, Kesanto Enterprises
> Your training in the cloud: <http://www.trainingcommons.com> 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/d/optout.

Reply via email to