Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8188459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:55:09+00:00 2026-06-07T02:55:09+00:00

I want to construct model with properties in form of lists. class Data(db.Model): listOfIntergers

  • 0

I want to construct model with properties in form of lists.

class Data(db.Model):
    listOfIntergers = db.ListProperty(int)
    listOfStrings = db.ListProperty(str)

On both list I want to keep list of values in range <0, 255>.

What property type will take less space including index listOfIntergers or listOfStrings in data store?

Consider that str could be characters or encoded hex value i.e. 0 = 0, 255 = ff.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T02:55:11+00:00Added an answer on June 7, 2026 at 2:55 am

    Be careful! First of all, integers are encoded using a variable-length encoding, so not all int64 values take up 8 bytes — small values take up 1-2 bytes. However, the representation of list properties repeats the property name for each value in the list. I rewrote your example using NDB (because the API for getting the encoded protobuf out of it is easier to remember) and found the following:

    >>> from ndb import *
    >>> class Data(Model):
    ...   listOfIntegers = IntegerProperty(repeated=True)
    ...   listOfStrings = StringProperty(repeated=True)
    ... 
    >>> len(Data()._to_pb().Encode())
    20
    >>> len(Data(listOfIntegers=[0]*100)._to_pb().Encode())
    2420
    >>> len(Data(listOfIntegers=[255]*100)._to_pb().Encode())
    2520
    >>> len(Data(listOfStrings=['\x00']*100)._to_pb().Encode())
    2420
    

    But notice how deceptive: 100 integers of value 0 take 24 bytes per value (most of that is the property name ‘listOfIntegers’), but 100 integers of value 255 take 25 bytes per value! That’s the variable-length encoding for you. 100 strings of value ‘\x00’ take 24 bytes per value too — but notice that ‘listOfStrings’ is one character shorter than ‘listOfIntegers’ so the 1-byte string takes up 1 byte more than the integer 0, and the same amount of space as the integer 255.

    Unless you really need this field to be indexed, the proper solution is probably to declare a BlobProperty (not a list/repeated property) and store a single string consisting of the desired number of bytes.

    >>> class Data(Model):
    ...  b = BlobProperty()
    ... 
    >>> d = Data(b=''.join(map(chr, range(100))))
    >>> len(d._to_pb().Encode())
    133
    >>> 
    

    That’s nearly 20x as compact for the same amount of information! (Admittedly you could get the list property version down a bit by using a shorter property name, but it would still be way longer.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to construct a string with an array of objects for (int n=0;
I want to use the DbProvider class to construct a generic DAL component. This
I want to create several properties on the fly inside the class' constructor and
I have a model where I want to translate the form validation error. So
I want to construct a context menu with a menu item for selecting a
In a Windows batch file, I want to construct a classpath of .jar files
i want to realize a construct in MS SQL that would look like this
I am building DB class, in the constructor I want to establish the connection
I want to run the constructor of the Main.class in the package Test2, located
I have a model which looks like this: class Example (db.Model) : row_num =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.