[issue34312] Allow str.endswith and str.startswith to accept an iterable

2018-08-03 Thread Brett Cannon
Change by Brett Cannon : -- resolution: -> wont fix stage: -> resolved status: open -> closed ___ Python tracker ___ ___

[issue34312] Allow str.endswith and str.startswith to accept an iterable

2018-08-03 Thread Stéphane Wirtel
Stéphane Wirtel added the comment: I also agree with the problem of performance, tuple and str are immutables and from that, we can optimize the generation of the bytecode. Raymond, @Brett & @Serhiy, Can we close this issue? -- nosy: +matrixise

[issue34312] Allow str.endswith and str.startswith to accept an iterable

2018-08-03 Thread Tal Einat
Tal Einat added the comment: I tend to agree. ISTM that for users, understanding the error message and passing a tuple is trivial, while realizing the performance benefit of using a tuple rather than a list or set here is certainly non-trivial. --

[issue34312] Allow str.endswith and str.startswith to accept an iterable

2018-08-02 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Teammate of mine tripped up against this because he tried to use a list. Then, I recommend we close this. Accepting a list would have encouraged inefficient code (a tuple of constants can be peephole optimized but a list of constants is rebuilt on

[issue34312] Allow str.endswith and str.startswith to accept an iterable

2018-08-02 Thread Brett Cannon
Brett Cannon added the comment: Teammate of mine tripped up against this because he tried to use a list. -- ___ Python tracker ___

[issue34312] Allow str.endswith and str.startswith to accept an iterable

2018-08-02 Thread Tal Einat
Change by Tal Einat : -- nosy: +taleinat ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue34312] Allow str.endswith and str.startswith to accept an iterable

2018-08-01 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I have same concerns as Raymond. -- nosy: +serhiy.storchaka ___ Python tracker ___ ___

[issue34312] Allow str.endswith and str.startswith to accept an iterable

2018-08-01 Thread Raymond Hettinger
Raymond Hettinger added the comment: ISTM that this would encourage silently inefficient coding patterns like: url.endswith({'.html', '.txt', '.php'}) # The set object gets rebuilt on every call # and a new set iterator object gets built on every call. # Looping over the contents

[issue34312] Allow str.endswith and str.startswith to accept an iterable

2018-08-01 Thread Brett Cannon
New submission from Brett Cannon : str.endswith() and str.startswith() only takes str or a tuple of str. It might be nice to make this str or an iterable of str (and that order must be kept so that a string isn't treated as an iterable of length-1 str). -- components: Interpreter