[Python-Dev] Unicode objects more space efficient than plain strings? can that be?

Guido van Rossum guido@python.org
Thu, 02 May 2002 08:37:06 -0400


[Skip notices that the second below eats much more memory than the first:]
>     l = [u"abc%d"%i for i in xrange(1000000)]
>     l = ["abc%d"%i for i in xrange(1000000)]

Yup, I can confirm this on Linux with a recent 2.3 build.  A 2.2 build
works as expected though (plain strings take up less space).  One for
the PyMalloc/GC team, I'm afraid...  (Using a debug build and
PYTHONDUMPREFS=1, I see no leaked objects.)

--Guido van Rossum (home page: http://www.python.org/~guido/)