[issue35897] Support list as argument to .startswith()

2022-02-18 Thread Fred


Fred  added the comment:

> For subtle reasons, that would make us worse off.  Tuple of constants get 
> precomputed but lists of constants have to be rebuilt.

So if a list is 20 times slower than a tuple, I can still do billions of 
computations in a second on a Raspberry Pi, so does it matter?

Being able to pass a list into .startswith() makes it more user-friendly and 
makes Python be more productive for the developer.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35897] Support list as argument to .startswith()

2022-02-18 Thread Jakub Wilk


Change by Jakub Wilk :


--
nosy: +jwilk

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35897] Support list as argument to .startswith()

2019-02-05 Thread Rémi Lapeyre

Rémi Lapeyre  added the comment:

> A programmer want to instruct the computer to do something, without having to 
> care about how it works.

This is not true, as a programmer you need to choose carefully your data 
structures because they matter, for example there is a difference between doing 
a lookup on an indexed field in an SQL database and a field that is not 
indexed. As a programmer you care because it impacts the performance of your 
application.

The linked discussion explains the difference between list and tuple in this 
instance.

@rhettinger: while this is not hard to fix, there is no mention in the 
documentation about why this choice has been made. A beginner don't know about 
the internals of cPython, should we add a small note about the optimization 
done with tuple?

--
nosy: +remi.lapeyre

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35897] Support list as argument to .startswith()

2019-02-05 Thread Fred .Flintstone


Fred .Flintstone  added the comment:

A programmer want to instruct the computer to do something, without having to 
care about how it works.

Maybe the library could in the background convert the list to a tuple.

Like:
"foo".startswith(tuple(["food", "for", "fast"]))

But the programmer shouldn't have to worry about this. I have a list, I want to 
use the list. I shouldn't have to care about interpreter internals that have 
nothing to do with the intent of my code.

My code should clearly represent intent, not have boilerplate code or 
constructs to workaround interpreter internals.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35897] Support list as argument to .startswith()

2019-02-05 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Related discussion : issue34312

--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35897] Support list as argument to .startswith()

2019-02-05 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

For subtle reasons, that would make us worse off.  Tuple of constants get 
precomputed but lists of constants have to be rebuilt.

Thank for the suggestion, but I think we should stick with the original design.

--
nosy: +rhettinger
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35897] Support list as argument to .startswith()

2019-02-05 Thread Fred .Flintstone


New submission from Fred .Flintstone :

The "".startswith() method accepts a string or a tuple as a parameter.

Consider adding support for list as parameter.

Example:
"foo".startswith(["food", "for", "fast"])

--
components: Interpreter Core
messages: 334856
nosy: Fred .Flintstone
priority: normal
severity: normal
status: open
title: Support list as argument to .startswith()
type: enhancement
versions: Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com