[Python-Dev] Why does read() return bytes instead of bytearray?

2009-04-14 Thread Dan Eloff
Hi,

Can someone please explain why read() should return an immutable bytes
type instead of a mutable bytearray? It's not like read() from a file
and use buffer as a key in a dict is common. Certainly read() from
file or stream, modify, write is very common. I don't understand why
the common case pays the price in performance and simplicity. It
seemed to me that the immutable bytes was described as being useful in
niche situations, but it actually seems to have been favored over
bytearray in Python 3.

Was there was a good reason for this decision? Or was this just an
artifact in the change to two bytes types?

The reason I ask is I have a server application that is mostly stream
reading/writing on the hot path and in Python 2.5 the redundant copies
add up to a significant overhead, (I estimate as much as 25% from my
measurements) I was looking at Python 3 as a way to solve that
problem, but unfortunately it doesn't look like it will help.

Thanks,
-Dan
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Why does read() return bytes instead of bytearray?

2009-04-14 Thread Dan Eloff
>No, the read() method did not change from the 2.x series. It returns a new 
>object on each call.

I think you misunderstand me, but the readinto() method looks like a
perfectly reasonable solution, I didn't realize it existed, as it's
not in the library reference on file objects. Thanks for enlightening
me, I feel a little stupid now :)

Python 3, lookout, here I come!

-Dan
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Thank you all

2006-09-15 Thread Dan Eloff
I was just browsing what's new in Python 2.5 at
http://docs.python.org/dev/whatsnew/

As I was reading I found myself thinking how almost every improvement
made a programming task I commonly bump into a little easier. Take the
with statement, or the new partition method for strings, or the
defaultdict (which I think was previously available, but I only now
realized what it does), or the unified try/except/finally, or the
conditional expression, etc

Then I remembered my reaction was much like that when python 2.4 was
released, and before that when Python 2.3 was released.

Every time a new version of python rolls around, my life gets a little easier.

I just want to say thank you, very much, from the bottom of my heart,
to everyone here who chooses to spend some of their free time working
on improving Python. Whether it be fixing bugs, writing documentation,
optimizing things, or adding new/updating modules or features, I want
you all to know I really appreciate your efforts. Your hard work has
long ago made Python into my favourite programming language, and the
gap only continues to grow. I think most people here and on
comp.lang.python feel the same way. It's just too often that people
(me) will find the 1% of things that aren't quite right and will focus
on that, rather than look at the 99% of things that are done very
well. So now, while I'm thinking about it, I want to take the
opportunity to say thank you for the 99% of Python that all of you
have done such a good job on.

-Dan
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com