Question

I want to store lists of integers (user ids), should I make them strings and use a StringListProperty, or just use a ListProperty, I'm wondering what is more optimized, the specific StringListProperty of the heterogeneous ListProperty (when used with only Integers).

I will need to add users to the list until it reaches a certain number, and then I create a group instance for those users (in a separate Entity Group).

Was it helpful?

Solution

StringListProperty is just a very thin wrapper around ListProperty. there's no meaningful difference other than element type.

from the code itself:

class StringListProperty(ListProperty):
  def __init__(self, verbose_name=None, default=None, **kwds):
    super(StringListProperty, self).__init__(basestring,
                                             verbose_name=verbose_name,
                                             default=default,
                                             **kwds)

i'd recommend storing integers in a plain ListProperty, since then you can query and sort them correctly, ie numerically, in datastore queries, which you can't do easily if you convert them to strings.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top