[Oberon] Python vs oberon: requirements to store 1 byte in memory

Paul Reed paulreed at paddedcell.com
Mon Feb 7 15:37:38 CET 2022


> In ... python ...:
>  >    sys.getsizeof('a') outputs 50 bytes of memory required for one
>  >    character (!) while in oberon, procedures SIZEOF(CHAR) or
>  >    Strings.Length("1") both give only 1...

I'm absolutely the *last* person to defend Python (!) but this doesn't 
seem to be a fair comparison because Python can't store one byte, it 
doesn't have such a data type. And Strings.Length is definitely not 
reporting any overhead, as thutt points out.

On the other hand, if some memory has been allocated to hold the string, 
in most systems it would usually involve some padding, so that appending 
to the string (for example) would not immediately require a new 
allocation and moving the data.

So I was a bit disappointed when I did

>>> import sys
>>> sys.getsizeof('ab')

and got 51. :(

Paul


More information about the Oberon mailing list