[Python-ideas] Adding __getter__ to compliment __iter__.
Nick Coghlan
ncoghlan at gmail.com
Fri Jul 19 06:59:29 CEST 2013
On 19 July 2013 00:29, Ron Adam <ron3200 at gmail.com> wrote:
> I was thinking a generator would be more efficient if it's called many
> times. But I think this is easier to understand. If there is more interest
> we can test both to see how much of a difference it makes.
Suspending and resuming a generator is quite an expensive operation.
send() has the triple whammy of method call + resume generator +
suspend generator, so it's unlikely to outperform a simple method call
(even one that redirects to another method).
Independent of performance though, I think the mutable sequence API
inspired append(), extend() and += are a better API for what you're
trying to achieve than "send", so it doesn't make sense to me to try
to shoehorn this into the generator API.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas
mailing list