<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Feb 8, 2014 at 8:17 AM, Mark Lawrence <span dir="ltr"><<a href="mailto:breamoreboy@yahoo.co.uk" target="_blank">breamoreboy@yahoo.co.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 08/02/2014 02:48, Steven D'Aprano wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Thu, 06 Feb 2014 05:51:54 -0800, wxjmfauth wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Sorry, I'm only pointing you may lose memory when working with short<br>
strings as it was explained. I really, very really, do not see what is<br>
absurd or obsure in:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

sys.getsizeof('abc' + 'EURO')<br>
</blockquote></blockquote></blockquote>
46<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

sys.getsizeof(('abc' + 'EURO').encode('utf-32'))<br>
</blockquote></blockquote></blockquote>
37<br>
</blockquote>
<br>
<br>
Why do you care about NINE bytes? The least amount of memory in any PC<br>
that I know about is 500000000 bytes, more than fifty million times more.<br>
And you are whinging about wasting nine bytes?<br></blockquote></blockquote><div><br></div><div>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? <br>
<br>Because it goes into the optimization of the code one is 'developing' in python.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

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

</div></div>