(original) (raw)
On Wed, Jan 9, 2013 at 8:31 AM, Guido van Rossum <guido@python.org> wrote:
On Tue, Jan 8, 2013 at 5:14 PM, Yuriy Taraday <yorik.sar@gmail.com> wrote:Thanks!
> I've read the PEP and some things raise questions in my consciousness. Here
> they are.
This is a semi-internal API that is mostly useful to Transport
\> 1\. Series of sock\_ methods can be organized into a wrapper around sock
\> object. This wrappers can then be saved and used later in async-aware code.
implementers, and there won't be many of those. So I prefer the API
that has the fewest classes.
Ditto.
\> 2\. Not as great, but still possible to wrap fd in similar way to make
\> interface simpler.
Ok, I see.
Should transports be bound to event loop on creation? I wonder, what would happen if someone changes current event loop between these calls.
Too late, this is how PEP 3148 defined it. It was indeed inspired by
\> 3\. Why not use properties (or fields) instead of methods for cancelled,
\> running and done in Future class? I think, it'll be easier to use since I
\> expect such attributes to be accessed as properties. I see it as some
\> javaism since in Java Future have getters for this fields but they are
\> prefixed with 'is'.
Java Futures. However I would defend using methods here, since these
are not all that cheap -- they have to acquire and release a lock.
I understand why it should be a method, but still if it's a getter, it should have either get\_ or is\_ prefix.
Are there any way to change this with 'Final' PEP?
\> 4\. Why separate exception() from result() for Future class? It does the sameBecause it is quite awkward to check for an exception if you have to
\> as result() but with different interface (return instead of raise). Doesn't
\> this violate the rule "There should be one obvious way to do it"?
catch it (4 lines instead of 1).
\> 5\. I think, protocol and transport methods' names are not easy orI am indeed struggling a bit with these names, but "writing an EOF" is
\> understanding enough:
\> - write\_eof() does not write anything but closes smth, should be
\> close\_writing or smth alike;
\> - the same way eof\_received() should become smth like receive\_closed;
actually how I think of this (maybe I am dating myself to the time of
mag tapes though :-).
I never saw a computer working with a tape, but it's clear to me what does they do.
I've just imagined the amount of words I'll have to say to students about EOFs instead of simple "it closes our end of one half of a socket".
\> - pause() and resume() work with reading only, so they should be suffixedAgreed.
\> (prefixed) with read(ing), like pause\_reading(), resume\_reading().
Kind regards, Yuriy.