[issue46574] itertools.count should work with non-number types

2022-01-29 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Thanks for the suggestion but I'm going to decline.

* The need for this is very low.  

* It's easy to roll your own.

* The code for `count('', 'a')` and `count((), (1,))` isn't intelligible.

* Without special casing, the code for `count('', 'a')` and `count((), (1,))` 
is highly inefficient.  We advise people not to use the 's = s + t' pattern in 
a loop for sequences because it leads to quadratic behavior.

--
assignee:  -> rhettinger
nosy: +rhettinger
resolution:  -> rejected
stage: patch review -> 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



[issue46574] itertools.count should work with non-number types

2022-01-29 Thread Vedran Čačić

Vedran Čačić  added the comment:

At one moment, I had a need for 

itertools.count(datetime.date.today(), datetime.timedelta(days=1))

Of course, it was no problem to write it myself, but still, it would be 
incredibly neat if it simply worked.

--
nosy: +veky

___
Python tracker 

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



[issue46574] itertools.count should work with non-number types

2022-01-29 Thread Roundup Robot


Change by Roundup Robot :


--
keywords: +patch
nosy: +python-dev
nosy_count: 1.0 -> 2.0
pull_requests: +29192
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/31013

___
Python tracker 

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



[issue46574] itertools.count should work with non-number types

2022-01-29 Thread Mital Ashok


New submission from Mital Ashok :

There's no reason that `count('', 'a')` for `'', 'a', 'aa', ...` or `count((), 
(1,))` for `(), (1,), (1, 1), ...` shouldn't work.

count(a, b) should be equivalent to accumulate(chain((a,), repeat(b)))

The docs don't strongly suggest that it won't work (it says *start* is a 
number, but the "roughly equivalent to" generator would work for str/tuple/etc)

--
components: Library (Lib)
messages: 412095
nosy: Mital Ashok
priority: normal
severity: normal
status: open
title: itertools.count should work with non-number types
type: enhancement
versions: Python 3.11

___
Python tracker 

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