[issue38237] Expose meaningful keyword arguments for pow()

2020-03-27 Thread miss-islington
miss-islington added the comment: New changeset 9c5c497ac167b843089553f6f62437d263382e97 by Miss Islington (bot) in branch '3.8': bpo-38237: Use divmod for positional arguments whatsnew example (GH-19171) https://github.com/python/cpython/commit/9c5c497ac167b843089553f6f62437d263382e97

[issue38237] Expose meaningful keyword arguments for pow()

2020-03-27 Thread miss-islington
Change by miss-islington : -- pull_requests: +18552 pull_request: https://github.com/python/cpython/pull/19192 ___ Python tracker ___

[issue38237] Expose meaningful keyword arguments for pow()

2020-03-27 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: New changeset 5a58c5280b8df4ca5d6a19892b24fff96e9ea868 by Ammar Askar in branch 'master': bpo-38237: Use divmod for positional arguments whatsnew example (GH-19171) https://github.com/python/cpython/commit/5a58c5280b8df4ca5d6a19892b24fff96e9ea868

[issue38237] Expose meaningful keyword arguments for pow()

2020-03-25 Thread Ammar Askar
Change by Ammar Askar : -- pull_requests: +18531 pull_request: https://github.com/python/cpython/pull/19171 ___ Python tracker ___

[issue38237] Expose meaningful keyword arguments for pow()

2020-03-19 Thread miss-islington
Change by miss-islington : -- pull_requests: +18436 pull_request: https://github.com/python/cpython/pull/19079 ___ Python tracker ___

[issue38237] Expose meaningful keyword arguments for pow()

2020-03-17 Thread Berry Schoenmakers
Berry Schoenmakers added the comment: Maybe a use case in this direction: int(x, base=10). Because, if you type int(x='3', base=12) you get TypeError: 'x' is an invalid keyword argument for int() and x needs to be a positional-only to program this yourself. --

[issue38237] Expose meaningful keyword arguments for pow()

2020-03-17 Thread Ammar Askar
Ammar Askar added the comment: I don't think that matters. The example is supposed to just serve as an illustration, it doesn't need to encode the dunder dispatch semantics. The already existing example doesn't check for a __pow__. I'd picture it just as: return x//y, x%y --

[issue38237] Expose meaningful keyword arguments for pow()

2020-03-17 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: divmod() should be implemented via __divmod__ and __rdivmod__. And they should be looked up on the type, not instance. There is no easy way to express it in Python accurately. This would make the example too complex. --

[issue38237] Expose meaningful keyword arguments for pow()

2020-03-17 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It is hard to find a builtin which could be easy and clearly implemented in Python (it means no use of dunder methods). Maybe sorted()? def sorted(iterable, /, *, key=None, reverse=False): """Emulate the built in sorted() function""" result =

[issue38237] Expose meaningful keyword arguments for pow()

2020-03-17 Thread Ammar Askar
Ammar Askar added the comment: In my original PR I changed it to divmod: https://github.com/python/cpython/pull/16302/files#diff-986275b975a33c44c0aba973362516fa -- ___ Python tracker

[issue38237] Expose meaningful keyword arguments for pow()

2020-03-17 Thread Mark Dickinson
Mark Dickinson added the comment: > This example can simply be dropped now. It could be, but it would be better to replace it with a different example that works. Any suggestions? -- ___ Python tracker

[issue38237] Expose meaningful keyword arguments for pow()

2020-03-17 Thread Mark Dickinson
Change by Mark Dickinson : -- pull_requests: +18393 pull_request: https://github.com/python/cpython/pull/19042 ___ Python tracker ___

[issue38237] Expose meaningful keyword arguments for pow()

2020-03-17 Thread Berry Schoenmakers
Berry Schoenmakers added the comment: There seems to be a slight mixup with the built-in pow() function in Python 3.8.2. Currently, under https://docs.python.org/3/library/functions.html#pow it says: Changed in version 3.9: Allow keyword arguments. Formerly, only positional

[issue38237] Expose meaningful keyword arguments for pow()

2019-09-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Thank you for the explanation Raymond and sorry for the disturb. My mistake, I had not noticed the release manager's assent. -- ___ Python tracker

[issue38237] Expose meaningful keyword arguments for pow()

2019-09-21 Thread miss-islington
Change by miss-islington : -- pull_requests: +15901 pull_request: https://github.com/python/cpython/pull/16323 ___ Python tracker ___

[issue38237] Expose meaningful keyword arguments for pow()

2019-09-21 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset 24231ca75c721c8167a7394deb300727ccdcba51 by Raymond Hettinger (Miss Islington (bot)) in branch '3.8': bpo-38237: Shorter docstring (GH-16322) (GH-16323) https://github.com/python/cpython/commit/24231ca75c721c8167a7394deb300727ccdcba51

[issue38237] Expose meaningful keyword arguments for pow()

2019-09-21 Thread Raymond Hettinger
Raymond Hettinger added the comment: As noted in the checkin, this was backported with the release manager's assent. FWIW, pow() itself is an old feature, recently enhanced to support negative powers in a given modulus. When the enhancement went in, we should have done this as well.

[issue38237] Expose meaningful keyword arguments for pow()

2019-09-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Isn't it a new feature? Isn't it too later to add it to 3.8? -- nosy: +lukasz.langa status: closed -> open ___ Python tracker ___

[issue38237] Expose meaningful keyword arguments for pow()

2019-09-21 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset 37bc93552375cb1bc616927b5c1905bae3c0e99d by Raymond Hettinger (Miss Islington (bot)) in branch '3.8': bpo-38237: Let pow() support keyword arguments (GH-16302) (GH-16320)

[issue38237] Expose meaningful keyword arguments for pow()

2019-09-21 Thread miss-islington
Change by miss-islington : -- pull_requests: +15897 pull_request: https://github.com/python/cpython/pull/16320 ___ Python tracker ___

[issue38237] Expose meaningful keyword arguments for pow()

2019-09-20 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Thank you for your contribution Ammar! Nice work! -- ___ Python tracker ___ ___

[issue38237] Expose meaningful keyword arguments for pow()

2019-09-20 Thread miss-islington
miss-islington added the comment: New changeset 87d6cd3604e5c83c06339276228139f5e040b0e7 by Miss Islington (bot) (Ammar Askar) in branch 'master': bpo-38237: Make pow's arguments have more descriptive names and be keyword passable (GH-16302)

[issue38237] Expose meaningful keyword arguments for pow()

2019-09-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: Thanks Ammar -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue38237] Expose meaningful keyword arguments for pow()

2019-09-20 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: -> rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue38237] Expose meaningful keyword arguments for pow()

2019-09-20 Thread Ammar Askar
Ammar Askar added the comment: math.pow changes removed from PR -- ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue38237] Expose meaningful keyword arguments for pow()

2019-09-20 Thread Ammar Askar
Ammar Askar added the comment: Before == >python -m pyperf timeit "pow(2, 3)" --duplicate 10 Mean +- std dev: 242 ns +- 19 ns > python -m pyperf timeit "pow(2.0, 3.0)" --duplicate 10 Mean +- std dev: 197 ns +- 16 ns After = > python -m pyperf timeit "pow(2, 3)" --duplicate

[issue38237] Expose meaningful keyword arguments for pow()

2019-09-20 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: And pow(2.0, 3.0) please. -- ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue38237] Expose meaningful keyword arguments for pow()

2019-09-20 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Thank you. Could you please test simpler examples like pow(2, 3)? Please use the --duplicate option. -- ___ Python tracker ___

[issue38237] Expose meaningful keyword arguments for pow()

2019-09-20 Thread Mark Dickinson
Mark Dickinson added the comment: The proposal sounds reasonable to me. > should a similar change be made for `math.pow` for consistency's sake? I'd leave math.pow alone here. -- ___ Python tracker

[issue38237] Expose meaningful keyword arguments for pow()

2019-09-20 Thread Ammar Askar
Ammar Askar added the comment: Here's a little microbenchmark, let me know if there's anything specific you'd like to see: Before == > python -m pyperf timeit "from test.test_builtin import BuiltinTest; tst = > BuiltinTest()" -- "tst.test_pow()" Mean +- std dev: 3.80 us +- 0.23 us >

[issue38237] Expose meaningful keyword arguments for pow()

2019-09-20 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: You can use a lambda instead of partial: squared = lambda x: pow(x, 2) Proposed names look meaningful. But after adding support of keyword arguments please compare performance of the old and the new functions. I expect that the difference will be

[issue38237] Expose meaningful keyword arguments for pow()

2019-09-20 Thread Ammar Askar
Ammar Askar added the comment: I've made a PR, feel free to close it if you'd rather implement this yourself or this proposal won't be accepted :) -- ___ Python tracker ___

[issue38237] Expose meaningful keyword arguments for pow()

2019-09-20 Thread Ammar Askar
Change by Ammar Askar : -- keywords: +patch pull_requests: +15887 stage: -> patch review pull_request: https://github.com/python/cpython/pull/16302 ___ Python tracker ___

[issue38237] Expose meaningful keyword arguments for pow()

2019-09-20 Thread Ammar Askar
Ammar Askar added the comment: Actually quick question, should a similar change be made for `math.pow` for consistency's sake? -- ___ Python tracker ___

[issue38237] Expose meaningful keyword arguments for pow()

2019-09-20 Thread Ammar Askar
Ammar Askar added the comment: Looks like a solid proposal, I especially like the clarity for the 3-argument call. Often beginners ask about why there's a third argument in pow especially when teaching RSA and number-theoretic stuff. Do you mind if I take this on Raymond? -- nosy:

[issue38237] Expose meaningful keyword arguments for pow()

2019-09-20 Thread Raymond Hettinger
New submission from Raymond Hettinger : Current signature: pow(x, y, z=None, /) Proposed signature: pow(base, exp, mod=None) Benefits: * Meaningful and self-explanatory parameters in tooltips * Optionally clearer calls for the three argument form: pow(2, 5, mod=4) * More