itertools.flatten()? and copying generators/iterators.
Bengt Richter
bokr at oz.net
Tue Oct 28 17:20:02 EST 2003
On Tue, 28 Oct 2003 14:19:40 GMT, Alex Martelli <aleax at aleax.it> wrote:
>Francis Avila wrote:
> ...
>> Actually, I meant the exception testing. Isn't Alex suggesting something
>> like?:
>>
>> try:
>> seq+''
>> except:
>> seq is not a string
>> else:
>> seq is a string
>
>Right. Yes, if you have a lot of nonstrings this IS going to be
>substantially slower than isinstance tests. As usual, setting up
>a representative benchmark and measuring the effect is best.
>
>Of course, it's not easy to decide what IS representative, but
>let's give it a try:
>
I am a worrywart, I guess, but my reaction is 'Nicht finger-poken
in der blinken-machinen' etc ;-) IOW, without knowing exactly what kind of
blinken-machine seq is, I would fear triggering an unknown side effect
with seq+'', so I would not like such a test as part of library code without
at least having it documented with shout-caps in the doc strings.
Regards,
Bengt Richter
More information about the Python-list
mailing list