Python for philosophers

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon May 13 03:13:23 EDT 2013


Some further details on something mentioned about Python being 
"economical".

On Sun, 12 May 2013 16:17:02 +0200, Citizen Kant wrote:

> For example: I'm plainly aware that the word "python" looks shorten than
> "01110000 01111001 01110100 01101000 01101111 01101110". But it's
> shorten just for me and you and maybe for every single human, not for
> the computer. You type "python", and the language (so to speak) thinks
> "in my opinion you're not being economical enough coz with this you mean
> 01110000 01111001 01110100 01101000 01101111 01101110", and then mirrors
> the supposedly result in its particular context. My "shorten" points to
> what's shorten during and inside Python's runtime.

In fact, the string "python" is implemented differently in different 
versions of Python. Picking Python 2.7, it may be implemented something 
like this binary string:

???????? ???????? ???????? ???????? ???????? ???????? ????????
???????? ???????? ???????? ???????? ???????? ???????? 00000000
01110000 00000000 01111001 00000000 01110100 00000000 01101000
00000000 01101111 00000000 01101110 00000000 00000000

where the spaces are purely for the convenience of the reader, and the 
question marks are internal values that I don't know enough to give the 
correct value. (Although I can predict that at least two sets of eight 
question marks is probably "00000000 00000110", the length of the string.)

To be precise, this is with a "narrow build", a "wide build" is even more 
profligate with memory. 

I'm not trying to beat the original Poster up for making an error, but 
demonstrating just how badly off track you can get by trying to reason 
from first principles (as Plato may have done) instead of empirical study 
(as Aristotle or Bacon may have done). Knowledge of how things actually 
are beats understanding of how they ought to be every time.


-- 
Steven



More information about the Python-list mailing list