Re: [Python-Dev] Please reconsider PEP 479.

2014-11-25 Thread Greg
will make comprehensions and generators behave identically. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Greg
lable using either yield from f() or await f(). That would water down the error catching ability a bit, but it would allow interoperability with existing asyncio code. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/ma

Re: [Python-Dev] PEP 492: async/await in Python; v3

2015-04-28 Thread Greg
That seems unavoidable if the goal is for 'await' to only work on generators that are intended to implement coroutines, and not on generators that are intended to implement iterators. Because there's no way to tell them apart wi

Re: [Python-Dev] PEP 492 vs. PEP 3152, new round

2015-04-30 Thread Greg
mediately obvious that this is parsed as 'not (a + b)' rather than '(not a) + b'. The presence of one arbitrary and unintuitive thing in the grammar is not by itself a justification for adding another one. -- Greg ___ P

Re: [Python-Dev] PEP 492 vs. PEP 3152, new round

2015-04-30 Thread Greg
essary to be able to write the things we *do* want also happens to allow those. I don't see that as a problem worth worrying about. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe:

Re: [Python-Dev] Enable access to the AST for Python code

2015-05-21 Thread Greg
emantics*. You can't view it as simply a translation of the Python expression into a different language. I still think this is really a macro facility by a different name. I'm not saying that's a bad thing, just pointing it out.

Re: [Python-Dev] Deleting with setting C API functions

2015-12-02 Thread Greg
On 3/12/2015 5:41 a.m., Random832 wrote: Why bother with the dot? Why not rename 3.5 to Python 5, and then go to Python 6, etc, and then your "4.0" would be 10. Then we could call it Python X! Everything is better with an X in the name

Re: [Python-Dev] PEP 461 updates

2014-01-16 Thread Greg
nternal details of that debate make sense to the rest of us. The main thing is that a consensus seems to have been reached on bytes formatting being basically a good thing. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/m

Re: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

2013-04-25 Thread Greg
ut 15 being less than 42 . When we do that, we're using cardinal numbers (how many), not ordinal numbers (what order). -- Greg ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscr

Re: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

2013-04-25 Thread Greg
3 orange = 4 class __methods__: def wave(self, n=1): for _ in range(n): print('Waving', self) and have the metaclass pull the functions out of the __methods__ sub-object. -- Greg ___ Python-Dev mailing list P

Re: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

2013-04-25 Thread Greg
y are just to establish the relative ordering. They wouldn't be directly accessible once the values are created. To get an integer value corresponding to a Day value, you would have to do arithmetic: Day.wednesday - Day.sunday --> 3 -- Greg _

Re: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

2013-04-25 Thread Greg
ase for the recently advertised macro system? ("One, two, five..." runs for cover...) -- Greg ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/opt

Re: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

2013-04-25 Thread Greg
l, I think. -- Greg ___ 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

Re: [Python-Dev] PEP 450 adding statistics module

2013-09-08 Thread Greg
On 9/09/2013 5:52 a.m., Guido van Rossum wrote: Well, to me zip(*x) is unnatural, and it's inefficient when the arrays are long. Would it be worth having a transpose() function in the stdlib somewhere, that returns a view instead of copying the data? --

Re: [Python-Dev] Coroutines and PEP 380

2012-01-19 Thread Greg
all over the place, from the lowest to the highest levels. But that doesn't mean you need a correspondingly large number of locks. You can't look at a 'yield' and conclude that you need a lock there or tell what needs to be locked. There's no substi

Re: [Python-Dev] Exposing the Android platform existence to Python modules

2014-08-02 Thread Greg Ewing
Shiz wrote: I'm not sure a check to see if e.g. /system exists is really enough to conclude Python is running on Android on its own. Since MacOSX has /System and typically a case-insensitive file system, it certainly wouldn't. :-) -- Greg

Re: [Python-Dev] sum(...) limitation

2014-08-08 Thread Greg Ewing
nally I can't see why "bitwise and" on strings should be a better metaphor for concatenation that "addition". :-) -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscri

Re: [Python-Dev] Bytes path support

2014-08-19 Thread Greg Ewing
Ben Hoyt wrote: Does that mean that new APIs should explicitly not support bytes? > ... Bytes paths are essentially broken on Windows. But on Unix, paths are essentially bytes. What's the official policy for dealing with that? -- Greg __

Re: [Python-Dev] Bytes path support

2014-08-19 Thread Greg Ewing
Stephen J. Turnbull wrote: This case can be handled now using the surrogateescape error handler, So maybe the way to make bytes paths go away is to always use surrogateescape for paths on unix? -- Greg ___ Python-Dev mailing list Python-Dev

Re: [Python-Dev] Bytes path support

2014-08-20 Thread Greg Ewing
scandir() is not to support bytes paths, I'd suggest exposing the opendir() and readdir() system calls with bytes path support. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe:

Re: [Python-Dev] Bytes path support

2014-08-23 Thread Greg Ewing
needs to be prepared to try all the encodings it supports until it finds one that works well enough to decode the XML declaration, then it can find out the exact encoding used. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org

Re: [Python-Dev] surrogatepass - she's a witch, burn 'er! [was: Cleaning up ...]

2014-08-29 Thread Greg Ewing
-8 sequences of more than three bytes, so it's definitely not "UTF-8 plus lone surrogates". -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.

Re: [Python-Dev] RFC: PEP 475, Retry system calls failing with EINTR

2014-08-31 Thread Greg Ewing
? I think it's best if the functions in the os module remain thin wrappers that expose the OS functionality as fully and directly as possible. Anything else should be provided by higher-level facilities. -- Greg ___ Python-Dev mailing list Python

Re: [Python-Dev] RFC: PEP 475, Retry system calls failing with EINTR

2014-09-01 Thread Greg Ewing
n out of in the EINTR case. But what happens if the read returns *without* an EINTR? The signal handler will still raise an exception, which is either going to clobber the partial return value or mess up the code that does something with it. -- Greg ___

Re: [Python-Dev] PEP 394 - Clarification of what "python" command should invoke

2014-09-19 Thread Greg Ewing
Donald Stufft wrote: My biggest problem with ``python3``, is what happens after 3.9. Python2 technically includes 1.x versions as well, so it wouldn't be unprecedented for python3 to imply versions beyond 3.x. It would be a bit confusing, though. --

Re: [Python-Dev] PEP 394 - Clarification of what "python" command should invoke

2014-09-19 Thread Greg Ewing
taken a trip to the future in which you get kidnapped and tortured until you reveal where you hid them, and then nipped over there to take them back. Which means he *might* be able to avoid carrying out the actual torture now, as long as it doesn't create too big a t

Re: [Python-Dev] bytes-like objects

2014-10-05 Thread Greg Ewing
e that has read() and/or write() methods. But you can't create an object that supports the buffer protocol by implementing Python methods. I'm worried that using the term "bytes-like object" will lead people to ask "What methods do I have to implement to make my obj

Re: [Python-Dev] bytes-like objects

2014-10-05 Thread Greg Ewing
uot; could be rather confusing. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Re: [Python-Dev] Status of C compilers for Python on Windows

2014-10-27 Thread Greg Ewing
Those objecting to a mingw-built python seem to be assuming that such a thing will necessarily be incompatible with VS builds, but I don't see why that has to be the case. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.o

Re: [Python-Dev] Real-world use of Counter

2014-11-05 Thread Greg Ewing
at is worth whatever small benefit there might be, if any. Summary: Looks fine to me as it is. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Re: [Python-Dev] Please reconsider PEP 479.

2014-11-26 Thread Greg Ewing
d waffly at the moment. Currently, there are cases where list(x for x in xs if P(x)) works while [x for x in xs if P(x)] fails (when P(x) raises StopIteration). With the PEP, both cases will raise some exception That's a better explanation, I think. -- Greg __

Re: [Python-Dev] PEP 479 and asyncio

2014-11-28 Thread Greg Ewing
ub-iteration as usual and its value attribute gets assigned to x. As long as a Trollius coroutine behaves like something implementing the iterator protocol, it should continue to work fine with Return as a subclass of StopIteration. Or is there something non-obvious about

Re: [Python-Dev] advice needed: best approach to enabling "metamodules"?

2014-11-29 Thread Greg Ewing
that module dicts are not being cleared on shutdown any more? If so, then the lifetime problem mentioned here no longer exists. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe:

Re: [Python-Dev] advice needed: best approach to enabling "metamodules"?

2014-11-29 Thread Greg Ewing
features -- just removing a restriction that prevents an existing language mechanism from working in this case. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https

Re: [Python-Dev] advice needed: best approach to enabling "metamodules"?

2014-11-29 Thread Greg Ewing
Why does MyModuleSubtype have to be imported from pkgname? It would make more sense for it to be defined directly in __new__.py, wouldn't it? Isn't the purpose of separating stuff out into __new__.py precisely to avoid circularities like that? -- Greg __

Re: [Python-Dev] advice needed: best approach to enabling "metamodules"?

2014-11-30 Thread Greg Ewing
py importing it from another module, as long as it's not any of the modules that are going to be using it. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mai

Re: [Python-Dev] datetime nanosecond support (ctd?)

2014-12-11 Thread Greg Ewing
MRAB wrote: Maybe, also, strptime could support "%*f" to gobble as many digits as are available. The * would suggest that the number of digits is being supplied as a parameter. Maybe "%?f". -- Greg ___ Python-Dev mailing list P

Re: [Python-Dev] bytes & bytearray

2015-01-19 Thread Greg Ewing
Guido van Rossum wrote: On Mon, Jan 19, 2015 at 11:43 AM, Paul Sokolovsky <mailto:pmis...@gmail.com>> wrote: b.lower_inplace() b.lower_i() Please don't go there. The use cases are too rare. And if you have such a use case, it's not too hard to do b[:] =

Re: [Python-Dev] Why does STORE_MAP not take a parameter?

2015-01-21 Thread Greg Ewing
ation, evaluating the items one at a time requires less stack space, so the stack frame can be smaller. But as always, you can't be sure without measuring it, and this would be a good thing for someone interested to try out. -- Greg ___ Python-Dev ma

Re: [Python-Dev] Disassembly of generated comprehensions

2015-01-25 Thread Greg Ewing
omatically. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Re: [Python-Dev] Why co_names? Wouldn't be simpler to just use co_consts?

2015-01-28 Thread Greg Ewing
to a total of 256 of both. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Re: [Python-Dev] Encoding of PyFrameObject members

2015-02-07 Thread Greg Ewing
nvolved in doing that. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Re: [Python-Dev] (no subject)

2015-02-09 Thread Greg Ewing
would mean that you could simply do: func(**dict1 | dict(y=1) | dict2) Same again, multiple ** avoids construction of an itermediate dict. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev

Re: [Python-Dev] (no subject)

2015-02-09 Thread Greg Ewing
call to me. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Re: [Python-Dev] (no subject)

2015-02-09 Thread Greg Ewing
2, 3] + (4, 5, 6) is an error because it's not clear whether the programmer intended the result to be a list or a tuple. I think that's a good thing. Also, it would mean that [1, 2, 3] + foo == [1, 2, 3, "f", "o", "o"] which would be surprising

Re: [Python-Dev] (no subject)

2015-02-10 Thread Greg Ewing
in a comprehension, i.e. this is a syntax error: [item[0], item[1], item[n] for item in items] So we would be giving a meaning to something that doesn't currently have a meaning, rather than changing an existing meaning, if you see what I mean

Re: [Python-Dev] (no subject)

2015-02-10 Thread Greg Ewing
Victor Stinner wrote: Le 10 févr. 2015 06:48, "Greg Ewing" <mailto:greg.ew...@canterbury.ac.nz>> a écrit : > It could potentially be a little more efficient by > eliminating the construction of an intermediate list. Is it the case in the implementation? If it has to

Re: [Python-Dev] (no subject)

2015-02-10 Thread Greg Ewing
: File "", line 1, in TypeError: can't concat bytes to list >>> [1,2,3] + b"a" Traceback (most recent call last): File "", line 1, in TypeError: can only concatenate list (not "bytes") to list -- Greg _

Re: [Python-Dev] (no subject)

2015-02-11 Thread Greg Ewing
John Wong wrote: I am actually amazed to remember dict + dict is not possible... there must be a reason (performance??) for this... I think it's mainly because there is no obviously correct answer to the question of what to do about duplicate keys. --

Re: [Python-Dev] (no subject)

2015-02-11 Thread Greg Ewing
inconsistency already exists -- duplicate keys are allowed in dict literals but not calls: >>> {'a':1, 'a':2} {'a': 2} -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/

Re: [Python-Dev] subclassing builtin data structures

2015-02-13 Thread Greg Ewing
at is that constructors are class methods, not instance methods. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/arch

Re: [Python-Dev] PEP 441 - Improving Python ZIP Application Support

2015-02-16 Thread Greg Ewing
Paul Moore wrote: The alternative, I guess, is to have *no* default and write no shebang unless -p is specified. +1. That sounds like a very good idea to me. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman

Re: [Python-Dev] Emit SyntaxWarning on unrecognized backslash escapes?

2015-02-24 Thread Greg Ewing
7;t figure out why. There's probably a useful meta-lesson in there: test after making every change! -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/

Re: [Python-Dev] Emit SyntaxWarning on unrecognized backslash escapes?

2015-02-24 Thread Greg Ewing
re is room for a more pointed error message from functions that take pathnames on Windows. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/

Re: [Python-Dev] super() does not work during class initialization

2015-03-23 Thread Greg Ewing
much), as determining the order would happen at compile time. I don't think the compiler can determine the order in all cases. Consider: class Spam: if moon_is_full: alpha = 1 beta = 2 else: beta = 2 alpha = 1 --

Re: [Python-Dev] PEP 487 vs 422 (dynamic class decoration)

2015-04-02 Thread Greg Ewing
ent failure when you use the decorator but omit the mandatory base class that makes the decorator work correctly. Could the decorator be designed to detect that situation somehow? E.g. the first time the decorated method is called, check that the required base class

Re: [Python-Dev] PEP 487 vs 422 (dynamic class decoration)

2015-04-04 Thread Greg Ewing
Eric Snow wrote: I've felt for a long time that it would be helpful in some situations to have a reverse descriptor protocol. Can you elaborate on what you mean by that? -- Greg ___ Python-Dev mailing list Python-Dev@python.org

Re: [Python-Dev] async/await in Python; v2

2015-04-21 Thread Greg Ewing
this automatically from the fact that you can't make an ordinary call to a cofunction, and cocall combines a call and a yield-from. You have to go out of your way to get hold of the underlying iterator to use in a for-loop, etc. -- Greg ___ Python-

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Greg Ewing
making this the *actual* interpretation of "cocall f(x)". -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Greg Ewing
() to adapt a cofunction for use with something expecting a generator-based coroutine, e.g. codef my_task_func(arg): ... my_task = Task(costart(my_task_func, arg)) If you're willing to make changes, Task() et al could be made to recognise cofunctions and apply costart() wher

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Greg Ewing
await coro_gen()'. Maybe. I haven't thought that idea through properly yet. Possibly the answer is that you define such a function using an ordinary "def", to match the way it's called. The fact that it's an async generator is then indicated by the fact that it cont

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Greg Ewing
Yury Selivanov wrote: I think there is another way... instead of pushing GET_ITER ... YIELD_FROM opcodes, we'll need to replace GET_ITER with another one: GET_ITER_SPECIAL ... YIELD_FROM I'm lost. What Python code are you suggesting this would be generated from

Re: [Python-Dev] async/await in Python; v2

2015-04-22 Thread Greg Ewing
lly, highlights one of the things that's been bothering me about all this "async foo" stuff: "async def" looks like it *defines the function* asynchronously That bothers me a bit, too, but my main problem with it is the way it displaces the function na

Re: [Python-Dev] async/await in Python; v2

2015-04-23 Thread Greg Ewing
Yury Selivanov wrote: - If it's an object with __await__, return iter(object.__await__()) Is the iter() really needed? Couldn't the contract of __await__ be that it always returns an iterator? -- Greg ___ Python-Dev mailing list

Re: [Python-Dev] async/await in Python; v2

2015-04-23 Thread Greg Ewing
w) if isinstance(res, futures.Future) or inspect.isgenerator(res): res = yield from res To accommodate the possibility of func being a cofunction, you would need to add something like if is_cofunction(func): res = yield from costart(func, *args, **kw) else:

Re: [Python-Dev] async/await in Python; v2

2015-04-23 Thread Greg Ewing
is something they need to look up and learn about. Whereas they may think they already know what a "coroutine" is and not bother to look further. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/pyth

Re: [Python-Dev] async/await in Python; v2

2015-04-23 Thread Greg Ewing
Ludovic Gasc wrote: Not related, but one of my coworkers asked me if with the new syntax it will be possible to write an async decorator for coroutines. This is certainly possible with PEP 3152. The decorator just needs to be an ordinary function whose return value is a cofunction. -- Greg

Re: [Python-Dev] async/await in Python; v2

2015-04-23 Thread Greg Ewing
and forth between generators, to get something symmetric. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail

Re: [Python-Dev] async/await in Python; v2

2015-04-23 Thread Greg Ewing
bles a PEP 3152 cocall. That misses the point, which is that a cocall is a special kind of function call, not a special kind of yield-from. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscri

Re: [Python-Dev] async/await in Python; v2

2015-04-23 Thread Greg Ewing
n, then discover that it needs to be suspendable, so you need to track down all the places that call it, and all the places that call those, etc. PEP 3152 ensures that you get clear diagnostics if you miss any. -- Greg ___ Python-Dev mailing li

Re: [Python-Dev] async/await in Python; v2

2015-04-23 Thread Greg Ewing
ter is clearer, because it makes it very obvious that the body of func is *not* executed before the Task is constructed. The former makes it look as though the *result* of executing func with args is being passed to Task, rather than func itself. -- Greg __

Re: [Python-Dev] async/await in Python; v2

2015-04-23 Thread Greg Ewing
aware version of asyncio, they would all know about cofunctions and what to do with them. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options

Re: [Python-Dev] async/await in Python; v2

2015-04-23 Thread Greg Ewing
Paul Sokolovsky wrote: Greg Ewing wrote: You can also use a trampoline of some kind to relay values back and forth between generators, to get something symmetric. Yes, that's of course how coroutine frameworks were done long before "yield from" appeared and how Trollius

Re: [Python-Dev] PEP 3152 and yield from Future()

2015-04-23 Thread Greg Ewing
ible to suspend a cofunction if it's not possible to use yield? The currently published version of PEP 3152 is not really complete. A few things would need to be added to it, one of them being a suspend() builtin that has the same effect as y

Re: [Python-Dev] async/await in Python; v2

2015-04-23 Thread Greg Ewing
needs to have either a special flag or an __await__ method before it can have 'await' applied to it. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.

Re: [Python-Dev] PEP 3152 and yield from Future()

2015-04-23 Thread Greg Ewing
yncio, sock_recv would be a cofunction, so that would be just data = cocall loop.sock_recv(sock, 1024) -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/ma

Re: [Python-Dev] PEP 3152 and yield from Future()

2015-04-23 Thread Greg Ewing
tion, it's an *ordinary* function that returns an iterator. In the case of Future, what it needs to do is identical to Future.__iter__. So the code can be just def __cocall__(self): return iter(self) or equivalent. -- Greg ___ Python-D

Re: [Python-Dev] PEP 3152 and yield from Future()

2015-04-23 Thread Greg Ewing
ng you're going to be doing much in practice. If you're just going to immediately call the result, there's no point in returning a future -- just do it all in do_something(). -- Greg ___ Python-Dev mailing list Python-Dev@python.org h

Re: [Python-Dev] async/await in Python; v2

2015-04-24 Thread Greg Ewing
would seem least likely to cause breakage: def useful() async: -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/arch

Re: [Python-Dev] async/await in Python; v2

2015-04-24 Thread Greg Ewing
x27;t require modifying fut at all. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Re: [Python-Dev] async/await in Python; v2

2015-04-24 Thread Greg Ewing
that. It adds some things and changes some things, but it doesn't simplify anything. Your idea of syntaticaly forcing to use 'cocall' with parens is cute, You say that as though "forcing" the use of parens were a goal in itself. It's not -- it's a *consequence* o

Re: [Python-Dev] PEP 3152 and yield from Future()

2015-04-24 Thread Greg Ewing
Guido van Rossum wrote: I think this is the nail in PEP 3152's coffin. Seems more like a small tack to me. :-) I've addressed all the issues raised there in earlier posts. -- Greg ___ Python-Dev mailing list Python-Dev@python

Re: [Python-Dev] PEP 3152 and yield from Future()

2015-04-24 Thread Greg Ewing
understand the whole puzzle. IMO the PEP 492 better explains how pieces are put together ;-) Yes, it's written in a rather minimal style, sorry about that. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman

Re: [Python-Dev] PEP 3152 and yield from Future()

2015-04-24 Thread Greg Ewing
dvantage there is in keeping the future- returning part of the API. However, if we use the await()-cofunction idea, then a call to the initial version looks like cocall await(f(x)) and after the refactoring it becomes cocall await(cocall f(x)) That doesn't lo

Re: [Python-Dev] async/await in Python; v2

2015-04-24 Thread Greg Ewing
d here as well. for item in iter async: ... with something as x async: ... -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/op

Re: [Python-Dev] PEP 3152 and yield from Future()

2015-04-24 Thread Greg Ewing
Paul Moore wrote: On 24 April 2015 at 09:34, Greg Ewing wrote: cocall await(cocall f(x)) That doesn't look so bad to me. I've not been following this discussion (and coroutines make my head hurt) but this idiom looks like it's bound to result in people getting the idea t

Re: [Python-Dev] PEP 492 vs. PEP 3152, new round

2015-04-24 Thread Greg Ewing
' a prefix operator with the same precedence as unary minus would allow most reasonable usages, I think. The only reason "yield from" has such a constrained syntax is that it starts with "yield", which is similarly constrained. Since 'await' is a brand new keywo

Re: [Python-Dev] async/await in Python; v2

2015-04-24 Thread Greg Ewing
Wild idea: Let "@" mean "async" when it's directly in front of a keyword. Then we would have: @def f(): ... @for x in iter: ... @with context as thing: ... -- Greg ___ Python-Dev mailing list Py

Re: [Python-Dev] PEP 492 vs. PEP 3152, new round

2015-04-24 Thread Greg Ewing
d of error, and that what there is will only be active in a special debug mode. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/pytho

Re: [Python-Dev] PEP 492 vs. PEP 3152, new round

2015-04-24 Thread Greg Ewing
utines" seems far too ambiguous. (There should be a Zen item something along the lines of "If you can't think of a concise and unambiguous name for it, it's probably a bad idea".) -- Greg ___ Python-Dev mailing list Python-D

Re: [Python-Dev] PEP 492 vs. PEP 3152, new round

2015-04-25 Thread Greg Ewing
ought of a way to do that yet, though. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Re: [Python-Dev] PEP 492 vs. PEP 3152, new round

2015-04-27 Thread Greg Ewing
ecedence as '-', i.e. replace factor: ('+'|'-'|'~') factor | power with factor: ('+'|'-'|'~'|'await') factor | power That would allow await a() res = await a() + await b() res = await await a() if aw

Re: [Python-Dev] PEP 492 vs. PEP 3152, new round

2015-04-28 Thread Greg Ewing
nd, seem to prevent x = - await a() which looks perfectly sensible to me. I don't like the idea of introducing another level of precedence. Python already has too many of those to keep in my brain. Being able to tell people "it's just like unary minus" makes it easy to explai

Re: [Python-Dev] PEP 492 vs. PEP 3152, new round

2015-04-29 Thread Greg Ewing
(-fut) Is there really a need to disallow that? It would take a fairly bizarre API to make it meaningful in the first place, but in any case, it's fairly clear what order of operations is intended without the parens. -- Greg ___ Python-Dev

Re: [Python-Dev] PEP 492: async/await in Python; v3

2015-04-29 Thread Greg Ewing
sallow *this*: # *Not* decorated with @coroutine def some_algorithm_impl(): yield 1 yield from iterator_implemented_by_generator() I hope to agree that this is a perfectly legitimate thing to do, and should remain so? -- Greg ___ Pyth

Re: [Python-Dev] PEP 492: async/await in Python; v3

2015-04-29 Thread Greg Ewing
what will break when they become real keywords. But I suppose that could be achieved by having both the hack *and* the __future__ import available. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-

Re: [Python-Dev] PEP 492 vs. PEP 3152, new round

2015-04-29 Thread Greg Ewing
Guido van Rossum wrote: I don't care for await await x. But do you dislike it enough to go out of your way to disallow it? -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubs

Re: [Python-Dev] PEP 492: async/await in Python; v3

2015-04-29 Thread Greg Ewing
on" seems like a clear and unabmigious way to refer to the former. I'm not sure what to call the latter. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Re: [Python-Dev] PEP 492: async/await in Python; v3

2015-04-29 Thread Greg Ewing
-- There is a proposal to add similar mechanism to ECMAScript 7 [2]_. A key difference is that JavaScript "async functions" always return a Promise. While this approach has some advantages, it also implies that a new Promise object is created on e

Re: [Python-Dev] PEP 492: async/await in Python; v3

2015-04-29 Thread Greg Ewing
Yury Selivanov wrote: On 2015-04-28 11:59 PM, Greg wrote: On 29/04/2015 9:49 a.m., Guido van Rossum wrote: *But* every generator-based coroutine *must* be decorated with `asyncio.coroutine()`. This is potentially a backwards incompatible change. See below. I worry about

  1   2   3   4   5   6   7   8   9   10   >