Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #65415 > unrolled thread

Finding size of Variable

Started byAyushi Dalmia <ayushidalmia2604@gmail.com>
First post2014-02-04 03:28 -0800
Last post2014-02-05 15:22 +0000
Articles 20 on this page of 137 — 29 participants

Back to article view | Back to comp.lang.python


Contents

  Finding size of Variable Ayushi Dalmia <ayushidalmia2604@gmail.com> - 2014-02-04 03:28 -0800
    Re: Finding size of Variable Peter Otten <__peter__@web.de> - 2014-02-04 12:40 +0100
      Re: Finding size of Variable Ayushi Dalmia <ayushidalmia2604@gmail.com> - 2014-02-04 04:43 -0800
        Re: Finding size of Variable Asaf Las <roegltd@gmail.com> - 2014-02-04 04:53 -0800
          Re: Finding size of Variable Ayushi Dalmia <ayushidalmia2604@gmail.com> - 2014-02-04 05:18 -0800
        Re: Finding size of Variable Dave Angel <davea@davea.name> - 2014-02-04 08:09 -0500
          Re: Finding size of Variable Ayushi Dalmia <ayushidalmia2604@gmail.com> - 2014-02-04 05:19 -0800
            Re: Finding size of Variable Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-02-04 09:06 -0500
              Re: Finding size of Variable Ayushi Dalmia <ayushidalmia2604@gmail.com> - 2014-02-04 21:00 -0800
    Re:Finding size of Variable Dave Angel <davea@davea.name> - 2014-02-04 14:21 -0500
      Re: Finding size of Variable Ayushi Dalmia <ayushidalmia2604@gmail.com> - 2014-02-04 21:15 -0800
        Re: Finding size of Variable Peter Otten <__peter__@web.de> - 2014-02-05 09:27 +0100
    Re: Finding size of Variable Tim Golden <mail@timgolden.me.uk> - 2014-02-04 19:28 +0000
    Re: Finding size of Variable Tim Chase <python.list@tim.thechases.com> - 2014-02-04 13:29 -0600
      Re: Finding size of Variable Ayushi Dalmia <ayushidalmia2604@gmail.com> - 2014-02-04 21:35 -0800
        Re: Finding size of Variable Rustom Mody <rustompmody@gmail.com> - 2014-02-04 21:45 -0800
          Re: Finding size of Variable Ayushi Dalmia <ayushidalmia2604@gmail.com> - 2014-02-04 22:00 -0800
        Re: Finding size of Variable Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-05 11:00 +0000
          Re: Finding size of Variable Chris Angelico <rosuav@gmail.com> - 2014-02-05 22:44 +1100
            Re: Finding size of Variable wxjmfauth@gmail.com - 2014-02-06 02:15 -0800
              Re: Finding size of Variable Ned Batchelder <ned@nedbatchelder.com> - 2014-02-06 06:10 -0500
                Re: Finding size of Variable wxjmfauth@gmail.com - 2014-02-06 05:51 -0800
                  Re: Finding size of Variable wxjmfauth@gmail.com - 2014-02-06 06:15 -0800
                  Re: Finding size of Variable Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-08 02:48 +0000
                    Re: Finding size of Variable Ethan Furman <ethan@stoneleaf.us> - 2014-02-07 19:02 -0800
                    Re: Finding size of Variable Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-08 13:17 +0000
                    Re: Finding size of Variable David Hutto <dwightdhutto@gmail.com> - 2014-02-08 17:45 -0500
                      Re: Finding size of Variable Rustom Mody <rustompmody@gmail.com> - 2014-02-08 17:25 -0800
                        Re: Finding size of Variable David Hutto <dwightdhutto@gmail.com> - 2014-02-08 21:56 -0500
                        Re: Finding size of Variable Chris Angelico <rosuav@gmail.com> - 2014-02-09 13:59 +1100
                        Re: Finding size of Variable David Hutto <dwightdhutto@gmail.com> - 2014-02-08 22:07 -0500
                        Re: Finding size of Variable Ned Batchelder <ned@nedbatchelder.com> - 2014-02-08 22:09 -0500
                        Re: Finding size of Variable David Hutto <dwightdhutto@gmail.com> - 2014-02-08 22:09 -0500
                        Re: Finding size of Variable Ned Batchelder <ned@nedbatchelder.com> - 2014-02-08 22:16 -0500
                          Re: Finding size of Variable Rustom Mody <rustompmody@gmail.com> - 2014-02-08 19:30 -0800
                    Re: Finding size of Variable wxjmfauth@gmail.com - 2014-02-10 06:07 -0800
                      Re: Finding size of Variable Asaf Las <roegltd@gmail.com> - 2014-02-10 06:25 -0800
                        Re: Finding size of Variable Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-10 14:39 +0000
                      Re: Finding size of Variable Tim Chase <python.list@tim.thechases.com> - 2014-02-10 08:43 -0600
                        Re: Finding size of Variable wxjmfauth@gmail.com - 2014-02-11 10:53 -0800
                          Re: Finding size of Variable Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-11 19:04 +0000
                            Re: Finding size of Variable wxjmfauth@gmail.com - 2014-02-11 23:49 -0800
                              Re: Finding size of Variable Chris Angelico <rosuav@gmail.com> - 2014-02-12 19:06 +1100
                                Re: Finding size of Variable Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-02-12 10:57 +0200
                                  Re: Finding size of Variable Chris Angelico <rosuav@gmail.com> - 2014-02-12 20:24 +1100
                                    Re: Finding size of Variable Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-02-12 11:35 +0200
                              Working with the set of real numbers (was: Finding size of Variable) Ben Finney <ben+python@benfinney.id.au> - 2014-02-12 19:17 +1100
                                Re: Working with the set of real numbers (was: Finding size of Variable) wxjmfauth@gmail.com - 2014-02-12 00:35 -0800
                                  Re: Working with the set of real numbers (was: Finding size of Variable) wxjmfauth@gmail.com - 2014-02-12 00:46 -0800
                                  Re: Working with the set of real numbers Ben Finney <ben+python@benfinney.id.au> - 2014-02-12 19:52 +1100
                                Re: Working with the set of real numbers (was: Finding size of Variable) Grant Edwards <invalid@invalid.invalid> - 2014-02-12 15:24 +0000
                                  Re: Working with the set of real numbers (was: Finding size of Variable) "Gisle Vanem" <gvanem@yahoo.no> - 2014-02-12 17:23 +0100
                              Re: Working with the set of real numbers (was: Finding size of Variable) Chris Angelico <rosuav@gmail.com> - 2014-02-12 19:47 +1100
                                Re: Working with the set of real numbers (was: Finding size of Variable) Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-02-12 11:23 +0200
                                Re: Working with the set of real numbers (was: Finding size of Variable) albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-03-04 02:45 +0000
                                  Re: Working with the set of real numbers (was: Finding size of Variable) Chris Angelico <rosuav@gmail.com> - 2014-03-04 14:02 +1100
                                    Re: Working with the set of real numbers (was: Finding size of Variable) Rustom Mody <rustompmody@gmail.com> - 2014-03-03 19:13 -0800
                                      Re: Working with the set of real numbers (was: Finding size of Variable) Chris Angelico <rosuav@gmail.com> - 2014-03-04 14:46 +1100
                                        Re: Working with the set of real numbers (was: Finding size of Variable) Rustom Mody <rustompmody@gmail.com> - 2014-03-03 21:19 -0800
                                        Re: Working with the set of real numbers (was: Finding size of Variable) Steven D'Aprano <steve@pearwood.info> - 2014-03-04 05:53 +0000
                                          Re: Working with the set of real numbers (was: Finding size of Variable) Chris Angelico <rosuav@gmail.com> - 2014-03-04 17:35 +1100
                                            Re: Working with the set of real numbers Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-03-05 00:05 +1300
                                              Re: Working with the set of real numbers Chris Angelico <rosuav@gmail.com> - 2014-03-04 23:43 +1100
                                            Re: Working with the set of real numbers Marko Rauhamaa <marko@pacujo.net> - 2014-03-04 21:49 +0200
                                              Re: Working with the set of real numbers Chris Angelico <rosuav@gmail.com> - 2014-03-05 06:58 +1100
                                              Re: Working with the set of real numbers Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2014-03-04 20:55 +0000
                                                Re: Working with the set of real numbers Marko Rauhamaa <marko@pacujo.net> - 2014-03-04 23:05 +0200
                                                  Re: Working with the set of real numbers Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2014-03-04 22:08 +0000
                                              Re: Working with the set of real numbers Chris Angelico <rosuav@gmail.com> - 2014-03-05 08:18 +1100
                                              Re: Working with the set of real numbers Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2014-03-04 22:02 +0000
                                              Re: Working with the set of real numbers Chris Angelico <rosuav@gmail.com> - 2014-03-05 09:18 +1100
                                              Re: Working with the set of real numbers Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2014-03-04 22:54 +0000
                                              Re: Working with the set of real numbers Chris Angelico <rosuav@gmail.com> - 2014-03-05 10:01 +1100
                                              Re: Working with the set of real numbers Dave Angel <davea@davea.name> - 2014-03-04 18:20 -0500
                                          Re: Working with the set of real numbers (was: Finding size of Variable) Ian Kelly <ian.g.kelly@gmail.com> - 2014-03-04 04:19 -0700
                                            Re: Working with the set of real numbers (was: Finding size of Variable) albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-03-05 02:27 +0000
                                          Re: Working with the set of real numbers (was: Finding size of Variable) Ian Kelly <ian.g.kelly@gmail.com> - 2014-03-04 04:23 -0700
                                    Re: Working with the set of real numbers (was: Finding size of Variable) albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-03-05 02:15 +0000
                                      Re: Working with the set of real numbers (was: Finding size of Variable) Steven D'Aprano <steve@pearwood.info> - 2014-03-05 03:41 +0000
                                        Re: Working with the set of real numbers (was: Finding size of Variable) Rustom Mody <rustompmody@gmail.com> - 2014-03-04 20:15 -0800
                                          Re: Working with the set of real numbers (was: Finding size of Variable) Roy Smith <roy@panix.com> - 2014-03-04 23:25 -0500
                                            Re: Working with the set of real numbers Ben Finney <ben+python@benfinney.id.au> - 2014-03-05 15:37 +1100
                                              Re: Working with the set of real numbers Rustom Mody <rustompmody@gmail.com> - 2014-03-04 20:57 -0800
                                              Re: Working with the set of real numbers Roy Smith <roy@panix.com> - 2014-03-05 00:29 -0500
                              Re: Working with the set of real numbers Ben Finney <ben+python@benfinney.id.au> - 2014-02-12 19:56 +1100
                              Re: Working with the set of real numbers Chris Angelico <rosuav@gmail.com> - 2014-02-12 20:16 +1100
                              Re: Working with the set of real numbers Ben Finney <ben+python@benfinney.id.au> - 2014-02-12 21:07 +1100
                                Re: Working with the set of real numbers Rustom Mody <rustompmody@gmail.com> - 2014-02-12 06:11 -0800
                                  Re: Working with the set of real numbers Ian Kelly <ian.g.kelly@gmail.com> - 2014-02-12 13:45 -0700
                                    Re: Working with the set of real numbers Rustom Mody <rustompmody@gmail.com> - 2014-02-12 17:47 -0800
                                Re: Working with the set of real numbers Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-02-13 11:09 +1300
                                Re: Working with the set of real numbers Steven D'Aprano <steve@pearwood.info> - 2014-02-13 03:31 +0000
                                  Re: Working with the set of real numbers Ben Finney <ben+python@benfinney.id.au> - 2014-02-13 14:45 +1100
                                  Re: Working with the set of real numbers Chris Angelico <rosuav@gmail.com> - 2014-02-13 15:17 +1100
                              Re: Working with the set of real numbers Chris Angelico <rosuav@gmail.com> - 2014-02-12 21:20 +1100
                                Re: Working with the set of real numbers wxjmfauth@gmail.com - 2014-02-12 02:55 -0800
                                  Re: Working with the set of real numbers Ned Batchelder <ned@nedbatchelder.com> - 2014-02-12 06:55 -0500
                                Re: Working with the set of real numbers Marko Rauhamaa <marko@pacujo.net> - 2014-02-12 14:48 +0200
                                  Re: Working with the set of real numbers Chris Angelico <rosuav@gmail.com> - 2014-02-13 00:20 +1100
                                    Re: Working with the set of real numbers Marko Rauhamaa <marko@pacujo.net> - 2014-02-12 16:13 +0200
                                      Re: Working with the set of real numbers Chris Angelico <rosuav@gmail.com> - 2014-02-13 04:52 +1100
                                        Re: Working with the set of real numbers Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-02-13 11:24 +1300
                                          Re: Working with the set of real numbers Dave Angel <davea@davea.name> - 2014-02-12 17:56 -0500
                                            Re: Working with the set of real numbers Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-02-14 18:26 +1300
                              Re: Working with the set of real numbers Ben Finney <ben+python@benfinney.id.au> - 2014-02-12 22:44 +1100
                              Re: Working with the set of real numbers Chris Angelico <rosuav@gmail.com> - 2014-02-12 22:58 +1100
                                Re: Working with the set of real numbers Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-02-13 11:32 +1300
                                  Re: Working with the set of real numbers Grant Edwards <invalid@invalid.invalid> - 2014-02-12 23:23 +0000
                              Re: Finding size of Variable Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-12 14:04 +0000
                                Re: Finding size of Variable Rustom Mody <rustompmody@gmail.com> - 2014-02-12 06:14 -0800
                                  Re: Finding size of Variable Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-12 14:25 +0000
                                    Re: Finding size of Variable Rustom Mody <rustompmody@gmail.com> - 2014-02-12 06:32 -0800
                              Re: Working with the set of real numbers Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2014-02-13 12:48 +0000
                                Re: Working with the set of real numbers Marko Rauhamaa <marko@pacujo.net> - 2014-02-13 16:00 +0200
                                  Re: Working with the set of real numbers Chris Angelico <rosuav@gmail.com> - 2014-02-14 06:25 +1100
                                    Re: Working with the set of real numbers Marko Rauhamaa <marko@pacujo.net> - 2014-02-13 21:47 +0200
                                      Re: Working with the set of real numbers Chris Angelico <rosuav@gmail.com> - 2014-02-14 07:08 +1100
                                      Re: Working with the set of real numbers Devin Jeanpierre <jeanpierreda@gmail.com> - 2014-02-13 22:05 -0800
                                        Re: Working with the set of real numbers Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-02-15 00:30 +1300
                                          Re: Working with the set of real numbers Devin Jeanpierre <jeanpierreda@gmail.com> - 2014-02-14 16:26 -0800
                                      Re: Working with the set of real numbers albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-03-05 02:38 +0000
                                    Re: Working with the set of real numbers Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-02-14 19:37 +1300
                                      Re: Working with the set of real numbers Chris Angelico <rosuav@gmail.com> - 2014-02-14 17:44 +1100
                                        Re: Working with the set of real numbers Rustom Mody <rustompmody@gmail.com> - 2014-02-14 07:13 -0800
                                      Re: Working with the set of real numbers Dave Angel <davea@davea.name> - 2014-02-14 07:30 -0500
                                      Re: Working with the set of real numbers Grant Edwards <invalid@invalid.invalid> - 2014-02-14 15:09 +0000
                                  Re: Working with the set of real numbers Rotwang <sg552@hotmail.co.uk> - 2014-02-13 21:29 +0000
                                    Re: Working with the set of real numbers Marko Rauhamaa <marko@pacujo.net> - 2014-02-14 00:00 +0200
                                      Re: Working with the set of real numbers Rotwang <sg552@hotmail.co.uk> - 2014-02-13 22:21 +0000
                                        Re: Working with the set of real numbers Marko Rauhamaa <marko@pacujo.net> - 2014-02-14 01:16 +0200
                              Re: Working with the set of real numbers Ben Finney <ben+python@benfinney.id.au> - 2014-02-14 03:57 +1100
                      Re: Finding size of Variable Ned Batchelder <ned@nedbatchelder.com> - 2014-02-10 10:02 -0500
                      Re: Finding size of Variable Neil Cerutti <neilc@norwich.edu> - 2014-02-11 14:29 +0000
          Re: Finding size of Variable Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-02-05 22:14 -0500
        Re: Finding size of Variable Dave Angel <davea@davea.name> - 2014-02-05 08:43 -0500
          Re: Finding size of Variable Ayushi Dalmia <ayushidalmia2604@gmail.com> - 2014-02-05 06:33 -0800
            Re: Finding size of Variable Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-05 15:22 +0000

Page 2 of 7 — ← Prev page 1 [2] 3 4 5 6 7  Next page →


#65529

FromNed Batchelder <ned@nedbatchelder.com>
Date2014-02-06 06:10 -0500
Message-ID<mailman.6441.1391685020.18130.python-list@python.org>
In reply to#65528
On 2/6/14 5:15 AM, wxjmfauth@gmail.com wrote:

>>>>
>>>> sum([sys.getsizeof(c) for c in ['a', 'a EURO', 'aa EURO']*3])
> 336
>>>> sum([sys.getsizeof(c) for c in ['aa EURO aa EURO']*3])
> 150
>>>> sum([sys.getsizeof(c.encode('utf-32')) for c in ['a', 'a EURO', 'aa EURO']*3])
> 261
>>>> sum([sys.getsizeof(c.encode('utf-32')) for c in ['aa EURO aa EURO']*3])
> 135
>>>>
>
> jmf
>

JMF, we've told you I-don't-know-how-many-times to stop this. 
Seriously: think hard about what your purpose is in sending these absurd 
benchmarks.  I guarantee you are not accomplishing it.

-- 
Ned Batchelder, http://nedbatchelder.com

[toc] | [prev] | [next] | [standalone]


#65537

Fromwxjmfauth@gmail.com
Date2014-02-06 05:51 -0800
Message-ID<888bd2fc-54b0-4c46-9d7b-d81d01a78b52@googlegroups.com>
In reply to#65529
Le jeudi 6 février 2014 12:10:08 UTC+1, Ned Batchelder a écrit :
> On 2/6/14 5:15 AM, wxjmfauth@gmail.com wrote:
> 
> 
> 
> >>>>
> 
> >>>> sum([sys.getsizeof(c) for c in ['a', 'a EURO', 'aa EURO']*3])
> 
> > 336
> 
> >>>> sum([sys.getsizeof(c) for c in ['aa EURO aa EURO']*3])
> 
> > 150
> 
> >>>> sum([sys.getsizeof(c.encode('utf-32')) for c in ['a', 'a EURO', 'aa EURO']*3])
> 
> > 261
> 
> >>>> sum([sys.getsizeof(c.encode('utf-32')) for c in ['aa EURO aa EURO']*3])
> 
> > 135
> 
> >>>>
> 
> >
> 
> > jmf
> 
> >
> 
> 
> 
> JMF, we've told you I-don't-know-how-many-times to stop this. 
> 
> Seriously: think hard about what your purpose is in sending these absurd 
> 
> benchmarks.  I guarantee you are not accomplishing it.
> 
> 
> 
> -- 
> 
> Ned Batchelder, http://nedbatchelder.com

Sorry, I'm only pointing you may lose memory when
working with short strings as it was explained.
I really, very really, do not see what is absurd
or obsure in:

>>> sys.getsizeof('abc' + 'EURO')
46
>>> sys.getsizeof(('abc' + 'EURO').encode('utf-32'))
37

I apologize for the " a EURO" which should have
been a real "EURO". No idea, what's happend.

jmf

[toc] | [prev] | [next] | [standalone]


#65540

Fromwxjmfauth@gmail.com
Date2014-02-06 06:15 -0800
Message-ID<806bd38d-27a2-41fd-a456-a85966f0cea3@googlegroups.com>
In reply to#65537
Some mysterious problem with the "euro".
Let's take a real "French" char.
>>> sys.getsizeof('abc' + 'œ')
46
>>> sys.getsizeof(('abc' + 'œ').encode('utf-32'))
37

or a "German" char, ẞẞẞẞẞ

>>> sys.getsizeof('abc' + '\N{LATIN CAPITAL LETTER SHARP S}')
46
>>> sys.getsizeof(('abc' + '\N{LATIN CAPITAL LETTER SHARP S}').encode('utf-32'))
37


[toc] | [prev] | [next] | [standalone]


#65618

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2014-02-08 02:48 +0000
Message-ID<52f59aeb$0$29972$c3e8da3$5496439d@news.astraweb.com>
In reply to#65537
On Thu, 06 Feb 2014 05:51:54 -0800, wxjmfauth wrote:

> Sorry, I'm only pointing you may lose memory when working with short
> strings as it was explained. I really, very really, do not see what is
> absurd or obsure in:
> 
>>>> sys.getsizeof('abc' + 'EURO')
> 46
>>>> sys.getsizeof(('abc' + 'EURO').encode('utf-32'))
> 37


Why do you care about NINE bytes? The least amount of memory in any PC 
that I know about is 500000000 bytes, more than fifty million times more. 
And you are whinging about wasting nine bytes?

If you care about that lousy nine bytes, Python is not the language for 
you. Go and program in C, where you can spent ten or twenty times longer 
programming, but save nine bytes in every string.

Nobody cares about your memory "benchmark" except you. Python is not 
designed to save memory, Python is designed to use as much memory as 
needed to give the programmer an easier job. In C, I can store a single 
integer in a single byte. In Python, horror upon horrors, it takes 14 
bytes!!!

py> sys.getsizeof(1)
14

We consider it A GOOD THING that Python spends memory for programmer 
convenience and safety. Python looks for memory optimizations when it can 
save large amounts of memory, not utterly trivial amounts. So in a Python 
wide build, a ten-thousand block character string requires a little bit 
more than 40KB. In Python 3.3, that can be reduced to only 10KB for a 
purely Latin-1 string, or 20K for a string without any astral characters. 
That's the sort of memory savings that are worthwhile, reducing memory 
usage by 75%.

Could Python save memory by using UTF-8? Yes. But it would cost 
complexity and time, strings would be even slower than they are now. That 
is not a trade-off that the core developers have chosen to make, and I 
agree with them.



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#65621

FromEthan Furman <ethan@stoneleaf.us>
Date2014-02-07 19:02 -0800
Message-ID<mailman.6505.1391830481.18130.python-list@python.org>
In reply to#65618
On 02/07/2014 06:48 PM, Steven D'Aprano wrote:
>
> That is not a trade-off that the core developers have chosen to make,
> and I agree with them.

Even though you haven't broken all the build-bots yet, you can still stop saying "them".  ;)

--
~Ethan~

[toc] | [prev] | [next] | [standalone]


#65676

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2014-02-08 13:17 +0000
Message-ID<mailman.6538.1391865456.18130.python-list@python.org>
In reply to#65618
On 08/02/2014 02:48, Steven D'Aprano wrote:
> On Thu, 06 Feb 2014 05:51:54 -0800, wxjmfauth wrote:
>
>> Sorry, I'm only pointing you may lose memory when working with short
>> strings as it was explained. I really, very really, do not see what is
>> absurd or obsure in:
>>
>>>>> sys.getsizeof('abc' + 'EURO')
>> 46
>>>>> sys.getsizeof(('abc' + 'EURO').encode('utf-32'))
>> 37
>
>
> Why do you care about NINE bytes? The least amount of memory in any PC
> that I know about is 500000000 bytes, more than fifty million times more.
> And you are whinging about wasting nine bytes?
>
> If you care about that lousy nine bytes, Python is not the language for
> you. Go and program in C, where you can spent ten or twenty times longer
> programming, but save nine bytes in every string.
>
> Nobody cares about your memory "benchmark" except you. Python is not
> designed to save memory, Python is designed to use as much memory as
> needed to give the programmer an easier job. In C, I can store a single
> integer in a single byte. In Python, horror upon horrors, it takes 14
> bytes!!!
>
> py> sys.getsizeof(1)
> 14
>
> We consider it A GOOD THING that Python spends memory for programmer
> convenience and safety. Python looks for memory optimizations when it can
> save large amounts of memory, not utterly trivial amounts. So in a Python
> wide build, a ten-thousand block character string requires a little bit
> more than 40KB. In Python 3.3, that can be reduced to only 10KB for a
> purely Latin-1 string, or 20K for a string without any astral characters.
> That's the sort of memory savings that are worthwhile, reducing memory
> usage by 75%.
>
> Could Python save memory by using UTF-8? Yes. But it would cost
> complexity and time, strings would be even slower than they are now. That
> is not a trade-off that the core developers have chosen to make, and I
> agree with them.
>
>
>

This is a C +1 to save memory when compared against this Python +1 :)

-- 
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

[toc] | [prev] | [next] | [standalone]


#65695

FromDavid Hutto <dwightdhutto@gmail.com>
Date2014-02-08 17:45 -0500
Message-ID<mailman.6550.1391899558.18130.python-list@python.org>
In reply to#65618

[Multipart message — attachments visible in raw view] — view raw

On Sat, Feb 8, 2014 at 8:17 AM, Mark Lawrence <breamoreboy@yahoo.co.uk>wrote:

> On 08/02/2014 02:48, Steven D'Aprano wrote:
>
>> On Thu, 06 Feb 2014 05:51:54 -0800, wxjmfauth wrote:
>>
>>  Sorry, I'm only pointing you may lose memory when working with short
>>> strings as it was explained. I really, very really, do not see what is
>>> absurd or obsure in:
>>>
>>>  sys.getsizeof('abc' + 'EURO')
>>>>>>
>>>>> 46
>>>
>>>> sys.getsizeof(('abc' + 'EURO').encode('utf-32'))
>>>>>>
>>>>> 37
>>>
>>
>>
>> Why do you care about NINE bytes? The least amount of memory in any PC
>> that I know about is 500000000 bytes, more than fifty million times more.
>> And you are whinging about wasting nine bytes?
>>
>
One could argue that if you're parsing a particular file, a very large one,
that those 9 bytes can go into the optimization of parsing aforementioned
file. Of, course we have faster processors, so why care?

Because it goes into the optimization of the code one is 'developing' in
python.


>
>> If you care about that lousy nine bytes, Python is not the language for
>> you. Go and program in C, where you can spent ten or twenty times longer
>> programming, but save nine bytes in every string.
>>
>> Nobody cares about your memory "benchmark" except you. Python is not
>> designed to save memory, Python is designed to use as much memory as
>> needed to give the programmer an easier job. In C, I can store a single
>> integer in a single byte. In Python, horror upon horrors, it takes 14
>> bytes!!!
>>
>> py> sys.getsizeof(1)
>> 14
>>
>> We consider it A GOOD THING that Python spends memory for programmer
>> convenience and safety. Python looks for memory optimizations when it can
>> save large amounts of memory, not utterly trivial amounts. So in a Python
>> wide build, a ten-thousand block character string requires a little bit
>> more than 40KB. In Python 3.3, that can be reduced to only 10KB for a
>> purely Latin-1 string, or 20K for a string without any astral characters.
>> That's the sort of memory savings that are worthwhile, reducing memory
>> usage by 75%.
>>
>> Could Python save memory by using UTF-8? Yes. But it would cost
>> complexity and time, strings would be even slower than they are now. That
>> is not a trade-off that the core developers have chosen to make, and I
>> agree with them.
>>
>>
>>
>>
> This is a C +1 to save memory when compared against this Python +1 :)
>
> --
> My fellow Pythonistas, ask not what our language can do for you, ask what
> you can do for our language.
>
> Mark Lawrence
>
> ---
> This email is free from viruses and malware because avast! Antivirus
> protection is active.
> http://www.avast.com
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>



-- 
Best Regards,
David Hutto
*CEO:* *http://www.hitwebdevelopment.com <http://www.hitwebdevelopment.com>*

[toc] | [prev] | [next] | [standalone]


#65702

FromRustom Mody <rustompmody@gmail.com>
Date2014-02-08 17:25 -0800
Message-ID<984cd62e-5a16-43fd-b6e0-f644d51aa450@googlegroups.com>
In reply to#65695
On Sunday, February 9, 2014 4:15:50 AM UTC+5:30, David Hutto wrote:
> One could argue that if you're parsing a particular file, a very large one, that those 9 bytes can go into the optimization of parsing aforementioned file. Of, course we have faster processors, so why care? 
> Because it goes into the optimization of the code one is 'developing' in python.

Yes... There are cases when python is an inappropriate language to use...
So???

Its good to get a bit of context here.

loop:
jmf says python is inappropriate.
Someone asks him: Is it? In what case?
jmf: No answer
After a delay of few days jmp to start of loop

[BTW: In my book this classic trolling]

[toc] | [prev] | [next] | [standalone]


#65711

FromDavid Hutto <dwightdhutto@gmail.com>
Date2014-02-08 21:56 -0500
Message-ID<mailman.6561.1391914575.18130.python-list@python.org>
In reply to#65702

[Multipart message — attachments visible in raw view] — view raw

On Sat, Feb 8, 2014 at 8:25 PM, Rustom Mody <rustompmody@gmail.com> wrote:

> On Sunday, February 9, 2014 4:15:50 AM UTC+5:30, David Hutto wrote:
> > One could argue that if you're parsing a particular file, a very large
> one, that those 9 bytes can go into the optimization of parsing
> aforementioned file. Of, course we have faster processors, so why care?
> > Because it goes into the optimization of the code one is 'developing' in
> python.
>
> Yes... There are cases when python is an inappropriate language to use...
> So???
>

I didn't say  she couldn't optimize in another language, and was just
prototyping in Python. I just said she was optimizing her python
code...dufus.



>
> Its good to get a bit of context here.
>
> loop:
> jmf says python is inappropriate.
> Someone asks him: Is it? In what case?
> jmf: No answer
> After a delay of few days jmp to start of loop
>
> loop:
mov head,up_your_ass
push  repeat
pop repeat
jmp loop

[BTW: In my book this classic trolling]
> --
>

And the title of this book would be..."Pieces of Cliche Bullshit Internet
Arguments for Dummies"

https://mail.python.org/mailman/listinfo/python-list
>



-- 
Best Regards,
David Hutto
*CEO:* *http://www.hitwebdevelopment.com <http://www.hitwebdevelopment.com>*

[toc] | [prev] | [next] | [standalone]


#65712

FromChris Angelico <rosuav@gmail.com>
Date2014-02-09 13:59 +1100
Message-ID<mailman.6562.1391914761.18130.python-list@python.org>
In reply to#65702
On Sun, Feb 9, 2014 at 1:56 PM, David Hutto <dwightdhutto@gmail.com> wrote:
>>
>> Yes... There are cases when python is an inappropriate language to use...
>> So???
>
>
> I didn't say  she couldn't optimize in another language, and was just
> prototyping in Python. I just said she was optimizing her python
> code...dufus.

And there are a *lot* of cases where that is inappropriate language to
use. Please don't.

ChrisA

[toc] | [prev] | [next] | [standalone]


#65713

FromDavid Hutto <dwightdhutto@gmail.com>
Date2014-02-08 22:07 -0500
Message-ID<mailman.6563.1391915232.18130.python-list@python.org>
In reply to#65702

[Multipart message — attachments visible in raw view] — view raw

On Sat, Feb 8, 2014 at 9:59 PM, Chris Angelico <rosuav@gmail.com> wrote:

> On Sun, Feb 9, 2014 at 1:56 PM, David Hutto <dwightdhutto@gmail.com>
> wrote:
> >>
> >> Yes... There are cases when python is an inappropriate language to
> use...
> >> So???
> >
> >
> > I didn't say  she couldn't optimize in another language, and was just
> > prototyping in Python. I just said she was optimizing her python
> > code...dufus.
>
> And there are a *lot* of cases where that is inappropriate language to
> use. Please don't.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>















it's also inappropriate for him to call people trolls, while they're just
commenting on why what she might be using is  a necessity for her
particular case of developing in Python, and not using another language,
yet.


"He started it!" :P

-- 
Best Regards,
David Hutto
*CEO:* *http://www.hitwebdevelopment.com <http://www.hitwebdevelopment.com>*

[toc] | [prev] | [next] | [standalone]


#65714

FromNed Batchelder <ned@nedbatchelder.com>
Date2014-02-08 22:09 -0500
Message-ID<mailman.6564.1391915377.18130.python-list@python.org>
In reply to#65702
On 2/8/14 9:56 PM, David Hutto wrote:
>
>
>
> On Sat, Feb 8, 2014 at 8:25 PM, Rustom Mody <rustompmody@gmail.com
> <mailto:rustompmody@gmail.com>> wrote:
>
>     On Sunday, February 9, 2014 4:15:50 AM UTC+5:30, David Hutto wrote:
>      > One could argue that if you're parsing a particular file, a very
>     large one, that those 9 bytes can go into the optimization of
>     parsing aforementioned file. Of, course we have faster processors,
>     so why care?
>      > Because it goes into the optimization of the code one is
>     'developing' in python.
>
>     Yes... There are cases when python is an inappropriate language to
>     use...
>     So???
>
>
> I didn't say  she couldn't optimize in another language, and was just
> prototyping in Python. I just said she was optimizing her python
> code...dufus.

Please keep the discussion respectful.  Misunderstandings are easy, I 
suspect this is one of them.  There's no reason to start calling people 
names.

>
>
>     Its good to get a bit of context here.
>
>     loop:
>     jmf says python is inappropriate.
>     Someone asks him: Is it? In what case?
>     jmf: No answer
>     After a delay of few days jmp to start of loop
>
> loop:
> mov head,up_your_ass
> push  repeat
> pop repeat
> jmp loop

Please keep in mind the Code of Conduct:

http://www.python.org/psf/codeofconduct

Thanks.

>
>     [BTW: In my book this classic trolling]
>     --
>
>
> And the title of this book would be..."Pieces of Cliche Bullshit
> Internet Arguments for Dummies"
>
>     https://mail.python.org/mailman/listinfo/python-list
>
>
>
>
> --
> Best Regards,
> David Hutto
> /*CEO:*/ _http://www.hitwebdevelopment.com_
>
>


-- 
Ned Batchelder, http://nedbatchelder.com

[toc] | [prev] | [next] | [standalone]


#65715

FromDavid Hutto <dwightdhutto@gmail.com>
Date2014-02-08 22:09 -0500
Message-ID<mailman.6565.1391915387.18130.python-list@python.org>
In reply to#65702

[Multipart message — attachments visible in raw view] — view raw

Maybe I'll just roll my fat, bald, troll arse out from under the bridge,
and comment back, off list, next time.

[toc] | [prev] | [next] | [standalone]


#65716

FromNed Batchelder <ned@nedbatchelder.com>
Date2014-02-08 22:16 -0500
Message-ID<mailman.6566.1391915821.18130.python-list@python.org>
In reply to#65702
On 2/8/14 10:09 PM, David Hutto wrote:
> Maybe I'll just roll my fat, bald, troll arse out from under the bridge,
> and comment back, off list, next time.
>
>

I'm not sure what happened in this thread.  It might be that you think 
Rustom Mody was referring to you when he said, "BTW: In my book this 
classic trolling."  I don't think he was, I think he was referring to JMF.

In any case, perhaps it would be best to just take a break?

-- 
Ned Batchelder, http://nedbatchelder.com

[toc] | [prev] | [next] | [standalone]


#65717

FromRustom Mody <rustompmody@gmail.com>
Date2014-02-08 19:30 -0800
Message-ID<a858c96d-0dae-4b7e-ae92-2defcc57b0ee@googlegroups.com>
In reply to#65716
On Sunday, February 9, 2014 8:46:50 AM UTC+5:30, Ned Batchelder wrote:
> On 2/8/14 10:09 PM, David Hutto wrote:
> > Maybe I'll just roll my fat, bald, troll arse out from under the bridge,
> > and comment back, off list, next time.

> I'm not sure what happened in this thread.  It might be that you think 
> Rustom Mody was referring to you when he said, "BTW: In my book this 
> classic trolling."  I don't think he was, I think he was referring to JMF.

Of course!
And given the turn of this thread, we must hand it to jmf for being even better at trolling than I thought :-)

See the first para
http://en.wikipedia.org/wiki/Troll_%28Internet%29

[toc] | [prev] | [next] | [standalone]


#65815

Fromwxjmfauth@gmail.com
Date2014-02-10 06:07 -0800
Message-ID<fe00e52f-80cb-4c19-b0a1-79bfe0c34051@googlegroups.com>
In reply to#65618
Le samedi 8 février 2014 03:48:12 UTC+1, Steven D'Aprano a écrit :
> 
> 
> We consider it A GOOD THING that Python spends memory for programmer 
> 
> convenience and safety. Python looks for memory optimizations when it can 
> 
> save large amounts of memory, not utterly trivial amounts. So in a Python 
> 
> wide build, a ten-thousand block character string requires a little bit 
> 
> more than 40KB. In Python 3.3, that can be reduced to only 10KB for a 
> 
> purely Latin-1 string, or 20K for a string without any astral characters. 
> 
> That's the sort of memory savings that are worthwhile, reducing memory 
> 
> usage by 75%.
> 
> 
> 

In its attempt to save memory, Python only succeeds to
do worse than any utf* coding schemes.

---

Python does not save memory at all. A str (unicode string)
uses less memory only - and only - because and when one uses
explicitly characters which are consuming less memory.

Not only the memory gain is zero, Python falls back to the
worse case.

>>> sys.getsizeof('a' * 1000000)
1000025
>>> sys.getsizeof('a' * 1000000 + 'oe')
2000040
>>> sys.getsizeof('a' * 1000000 + 'oe' + '\U00010000')
4000048

The opposite of what the utf8/utf16 do!

>>> sys.getsizeof(('a' * 1000000 + 'oe' + '\U00010000').encode('utf-8'))
1000023
>>> sys.getsizeof(('a' * 1000000 + 'oe' + '\U00010000').encode('utf-16'))
2000025


jmf

[toc] | [prev] | [next] | [standalone]


#65817

FromAsaf Las <roegltd@gmail.com>
Date2014-02-10 06:25 -0800
Message-ID<56be2de0-ab95-4dc6-a7c2-571ae8bc0e26@googlegroups.com>
In reply to#65815
On Monday, February 10, 2014 4:07:14 PM UTC+2, wxjm...@gmail.com wrote:
Interesting 

> >>> sys.getsizeof('a' * 1000000)
here you get string type 

> >>> sys.getsizeof(('a' * 1000000 + 'oe' + '\U00010000').encode('utf-8'))
and here bytes

>>> type ('a' * 10000)
<class 'str'>
>>> type(('a' * 1000000 + 'oe' + '\U00010000').encode('utf-8'))
<class 'bytes'>
>>>

Why? 

[toc] | [prev] | [next] | [standalone]


#65818

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2014-02-10 14:39 +0000
Message-ID<mailman.6622.1392043186.18130.python-list@python.org>
In reply to#65817
On 10/02/2014 14:25, Asaf Las wrote:
> On Monday, February 10, 2014 4:07:14 PM UTC+2, wxjm...@gmail.com wrote:
> Interesting
>
>>>>> sys.getsizeof('a' * 1000000)
> here you get string type
>
>>>>> sys.getsizeof(('a' * 1000000 + 'oe' + '\U00010000').encode('utf-8'))
> and here bytes
>
>>>> type ('a' * 10000)
> <class 'str'>
>>>> type(('a' * 1000000 + 'oe' + '\U00010000').encode('utf-8'))
> <class 'bytes'>
>>>>
>
> Why?
>

Please don't feed this particular troll, he's spent 18 months driving us 
nuts with his nonsense.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

[toc] | [prev] | [next] | [standalone]


#65819

FromTim Chase <python.list@tim.thechases.com>
Date2014-02-10 08:43 -0600
Message-ID<mailman.6623.1392043356.18130.python-list@python.org>
In reply to#65815
On 2014-02-10 06:07, wxjmfauth@gmail.com wrote:
> Python does not save memory at all. A str (unicode string)
> uses less memory only - and only - because and when one uses
> explicitly characters which are consuming less memory.
> 
> Not only the memory gain is zero, Python falls back to the
> worse case.
> 
> >>> sys.getsizeof('a' * 1000000)  
> 1000025
> >>> sys.getsizeof('a' * 1000000 + 'oe')  
> 2000040
> >>> sys.getsizeof('a' * 1000000 + 'oe' + '\U00010000')  
> 4000048

If Python used UTF-32 for EVERYTHING, then all three of those cases
would be 4000048, so it clearly disproves your claim that "python
does not save memory at all".

> The opposite of what the utf8/utf16 do!
> 
> >>> sys.getsizeof(('a' * 1000000 + 'oe' +
> >>> '\U00010000').encode('utf-8'))  
> 1000023
> >>> sys.getsizeof(('a' * 1000000 + 'oe' +
> >>> '\U00010000').encode('utf-16'))  
> 2000025

However, as pointed out repeatedly, string-indexing in fixed-width
encodings are O(1) while indexing into variable-width encodings (e.g.
UTF8/UTF16) are O(N).  The FSR gives the benefits of O(1) indexing
while saving space when a string doesn't need to use a full 32-bit
width.

-tkc


[toc] | [prev] | [next] | [standalone]


#65944

Fromwxjmfauth@gmail.com
Date2014-02-11 10:53 -0800
Message-ID<7cc8f49d-a4c7-48c2-a0af-ac58c847d794@googlegroups.com>
In reply to#65819
Le lundi 10 février 2014 15:43:08 UTC+1, Tim Chase a écrit :
> On 2014-02-10 06:07, wxjmfauth@gmail.com wrote:
> 
> > Python does not save memory at all. A str (unicode string)
> 
> > uses less memory only - and only - because and when one uses
> 
> > explicitly characters which are consuming less memory.
> 
> > 
> 
> > Not only the memory gain is zero, Python falls back to the
> 
> > worse case.
> 
> > 
> 
> > >>> sys.getsizeof('a' * 1000000)  
> 
> > 1000025
> 
> > >>> sys.getsizeof('a' * 1000000 + 'oe')  
> 
> > 2000040
> 
> > >>> sys.getsizeof('a' * 1000000 + 'oe' + '\U00010000')  
> 
> > 4000048
> 
> 
> 
> If Python used UTF-32 for EVERYTHING, then all three of those cases
> 
> would be 4000048, so it clearly disproves your claim that "python
> 
> does not save memory at all".
> 
> 
> 
> > The opposite of what the utf8/utf16 do!
> 
> > 
> 
> > >>> sys.getsizeof(('a' * 1000000 + 'oe' +
> 
> > >>> '\U00010000').encode('utf-8'))  
> 
> > 1000023
> 
> > >>> sys.getsizeof(('a' * 1000000 + 'oe' +
> 
> > >>> '\U00010000').encode('utf-16'))  
> 
> > 2000025
> 
> 
> 
> However, as pointed out repeatedly, string-indexing in fixed-width
> 
> encodings are O(1) while indexing into variable-width encodings (e.g.
> 
> UTF8/UTF16) are O(N).  The FSR gives the benefits of O(1) indexing
> 
> while saving space when a string doesn't need to use a full 32-bit
> 
> width.
> 
> 

A utf optimizes the memory and the performance at the same time.
It behaves like a mathematical operator, a unique operator for
a unique set of elements. Unbeatable.

The FSR is an exclusive or mechanism. I you wish to
same memory, you have to encode, and if you are encoding,
maybe because you have to, one loses performance. Paradoxal.

Your O(1) indexing works only and only because and
when you are working explicitly with a "static" unicode
string you never touch.
It's a little bit the the "corresponding" performance
case of the memory case.

jmf

[toc] | [prev] | [next] | [standalone]


Page 2 of 7 — ← Prev page 1 [2] 3 4 5 6 7  Next page →

Back to top | Article view | comp.lang.python


csiph-web