[issue34637] Make *start* usable as a keyword argument for sum().

2018-09-12 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Discussed exposure of the first argument with GPS and agreed that we don't want 
people writing API sum(iterable=[10,20,30], start=0).

Serhiy, yes this is a duplicate/superseder of issue31141.   Will close that at 
well.

--
resolution:  -> fixed
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



[issue34637] Make *start* usable as a keyword argument for sum().

2018-09-12 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset 9dfa0fe587eae3626ffc973680c6a17f35de3864 by Raymond Hettinger in 
branch 'master':
bpo-34637: Make the *start* argument for *sum()* visible as a keyword argument. 
(GH-9208)
https://github.com/python/cpython/commit/9dfa0fe587eae3626ffc973680c6a17f35de3864


--

___
Python tracker 

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



[issue34637] Make *start* usable as a keyword argument for sum().

2018-09-11 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

There doesn't seem to be any performance regression hoping that I am doing the 
benchmarks correctly. Some numbers for the PR.

# Master

git checkout master
git clean -xdf && ./configure && make -s -j4

$ cpython git:(master) ./python.exe
Python 3.8.0a0 (heads/master:731ff68eee, Sep 12 2018, 11:19:46)
[Clang 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

$ cpython git:(master) repeat 10 ./python.exe -m timeit "sum(range(10), 50)"
50 loops, best of 5: 635 nsec per loop
50 loops, best of 5: 682 nsec per loop
50 loops, best of 5: 637 nsec per loop
50 loops, best of 5: 648 nsec per loop
50 loops, best of 5: 618 nsec per loop
50 loops, best of 5: 621 nsec per loop
50 loops, best of 5: 653 nsec per loop
50 loops, best of 5: 624 nsec per loop
50 loops, best of 5: 671 nsec per loop
50 loops, best of 5: 659 nsec per loop

git fetch upstream pull/9208/head:sum-start-keyword
git checkout sum-start-keyword
git clean -xdf && ./configure && make -s -j4

$ cpython git:(sum-start-keyword) ./python.exe
Python 3.8.0a0 (heads/sum-start-keyword:71b890cd56, Sep 12 2018, 11:23:02)
[Clang 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

$ cpython git:(sum-start-keyword) repeat 10 ./python.exe -m timeit 
"sum(range(10), 50)"
50 loops, best of 5: 655 nsec per loop
50 loops, best of 5: 662 nsec per loop
50 loops, best of 5: 669 nsec per loop
50 loops, best of 5: 656 nsec per loop
50 loops, best of 5: 666 nsec per loop
50 loops, best of 5: 642 nsec per loop
50 loops, best of 5: 638 nsec per loop
50 loops, best of 5: 628 nsec per loop
50 loops, best of 5: 684 nsec per loop
50 loops, best of 5: 648 nsec per loop

$ cpython git:(sum-start-keyword) repeat 10 ./python.exe -m timeit 
"sum(range(10), start=50)"
50 loops, best of 5: 637 nsec per loop
50 loops, best of 5: 677 nsec per loop
50 loops, best of 5: 649 nsec per loop
50 loops, best of 5: 660 nsec per loop
50 loops, best of 5: 692 nsec per loop
50 loops, best of 5: 704 nsec per loop
50 loops, best of 5: 638 nsec per loop
50 loops, best of 5: 659 nsec per loop
50 loops, best of 5: 637 nsec per loop
50 loops, best of 5: 699 nsec per loop

I haven't tested the other PR serhiy mentioned since it has merge conflicts and 
I think it uses the same approach with argument clinic.


Thanks

--

___
Python tracker 

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



[issue34637] Make *start* usable as a keyword argument for sum().

2018-09-11 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Is not this a duplicate of issue31141?

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue34637] Make *start* usable as a keyword argument for sum().

2018-09-11 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +xtreak

___
Python tracker 

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



[issue34637] Make *start* usable as a keyword argument for sum().

2018-09-11 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
keywords: +patch
pull_requests: +8642
stage:  -> patch review

___
Python tracker 

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



[issue34637] Make *start* usable as a keyword argument for sum().

2018-09-11 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

I suggest also allowing the first argument to be a keyword named sequence= as 
well.  (along the philosophy of positional only arguments on APIs that happen 
to be implemented in C in CPython are a bad legacy)

pypy already uses these names:
 
https://bitbucket.org/pypy/pypy/src/4cbeaa8bf545332c36ae277019772aa432693e4c/pypy/module/__builtin__/app_functional.py?at=default&fileviewer=file-view-default#app_functional.py-41

--

___
Python tracker 

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



[issue34637] Make *start* usable as a keyword argument for sum().

2018-09-11 Thread Steve Dower


Steve Dower  added the comment:

Woo! Thanks Raymond!

--
nosy: +steve.dower

___
Python tracker 

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



[issue34637] Make *start* usable as a keyword argument for sum().

2018-09-11 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

+1 agreed.

--
nosy: +gregory.p.smith

___
Python tracker 

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



[issue34637] Make *start* usable as a keyword argument for sum().

2018-09-11 Thread Raymond Hettinger


New submission from Raymond Hettinger :

Currently, we can write:

>>> sum(range(10), 50)
95

What we want to allow:

>>> sum(range(10), start=50)
95

The positional form would still be allowed.

--
assignee: rhettinger
components: Library (Lib)
messages: 325092
nosy: rhettinger
priority: normal
severity: normal
status: open
title: Make *start* usable as a keyword argument for sum().
type: enhancement
versions: Python 3.8

___
Python tracker 

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