Pergunta

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).

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top