StringIO proposal: add __iadd__

T

Tom Anderson

By all means, the C versions are welcome, I just don't want to lose the
Python versions either (and making them less readable by recoding them
in RPython would interfere with didactical use).

Is RPython really that bad? Lack of generators seems like the only serious
issue to me.

Unless we use Shed Skin to translate the RPython into C++. Or maybe we
could write the code in Pyrex, generate C from that for CPython, then have
a python script which strips out the type definitions to generate pure
python for PyPy.

tom
 
R

Raymond Hettinger

[Raymond Hettinger]
[Paul Rubin]
Why would they need that?
Polymorphism

StringIO objects have getvalue() but other
file-like objects don't. What's wrong with __iadd__ being another
StringIO-specific operation?

The getvalue() method isn't a synonym for another method in the file
object API. Its design capitalizes on properties unique to StringIO
(direct access to the full buffer without rewinding the file pointer).

In contrast, the __iadd__() method is a synonym for write(). Its use
cases are the same for both StringIO and file objects.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top