3

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

Axel Fontaine
  • 34,542
  • 16
  • 106
  • 137
Alex Amato
  • 1,591
  • 4
  • 19
  • 32

1 Answers1

10

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.

ryan
  • 2,687
  • 1
  • 29
  • 38