Comments (14)
Could we do this deprecation as soon as possible with a list of all affected functions?
We'd need to approach such a deprecation extremely carefully. Each function changed would have to be evaluated separately to see if the tradeoff would be worth it for users of CPython. For each function, we'd have to consider:
- How common is it to pass a keyword argument to the parameter(s) we're considering changing? If it's common, and/or if it makes sense to be able to pass it by keyword, it may not be worth the disruption
- How much of a speedup are we talking for that function?
- How likely is it that that function would be used in performance-critical areas of a codebase, such that speeding up the function would offer a meaningful and noticeable improvement for users of CPython?
This isn't to say that we shouldn't make any changes here, necessarily. If there are builtin functions where it really makes no sense to pass an argument by keyword, it would speed the function up a lot to make a parameter positional-only, and we can't really find any uses in the wild of people passing it by keyword — for those functions, I think we could definitely consider starting a deprecation cycle so that we can eventually make them positional-only. We definitely can't do them all at once, though, I'm afraid :-)
from cpython.
I also think we should start with the private functions (starting with an underscore).
For those functions we just need to check if they're not exported as public functions.
(And of course don't break code in the stdlib).
from cpython.
Alex, you should probably also add the performance label, as this could greatly improve CPython's performance. :)
Unfortunately I don't think we'd see any immediate performance gains, as we'd have to undergo a deprecation period of at least two release cycles before making any parameters that are currently positional-or-keyword positional-only :/
from cpython.
This would break a lot of code. I don't think this is a good idea.
from cpython.
Won't this be mostly used for functions with readability problems or an unintuitive order, and usage with something like
functools.partial()
It's pretty hard to say in the abstract, which is why we'd need to consider each function individually before making a decision on whether to start the deprecation cycle :-) but anything that would require people to change code that was previously working counts as a backwards-compatibility breakage, so is subject to the policy in PEP-387
from cpython.
cc @erlend-aasland, @eendebakpt
from cpython.
Alex, you should probably also add the performance label, as this could greatly improve CPython's performance. :)
from cpython.
Damn that's really unfortunate. ;( Could we do this deprecation as soon as possible with a list of all affected functions?
from cpython.
But which code? I'm talking about functions with only required arguments.
All I can think of is usage with functools.partial()
which wouldn't apply to functions with a single argument!
from cpython.
We'd need to approach such a deprecation extremely carefully. Each function changed would have to be evaluated separately to see if the tradeoff would be worth it for users of CPython.
I agree, though we should use an approach that minimizes the required work (like only evaluating functions with 2 or more
required arguments and skipping infrequently used modules).
How common is it to pass a keyword argument to the parameter(s) we're considering changing? If it's common, and/or if it makes sense to be able to pass it by keyword, it may not be worth the disruption
Won't this be mostly used for functions with readability problems or an unintuitive order, and usage with something like functools.partial()
(which doesn't apply to functions with a single argument)?
We definitely can't do them all at once, though, I'm afraid
That's fine, but it's important that we discuss this.
from cpython.
Could we consider automatically updating all current clinic input to explicitely allow keyword arguments like in the proposal, and make arguments positional only by default if no keywords are provided?
Or would that lead to too many merge conflicts?
from cpython.
Could we consider automatically updating all current clinic input to explicitely allow keyword arguments like in the proposal, and make arguments positional only by default if no keywords are provided? Or would that lead to too many merge conflicts?
I'm not sure I fully understand what you're proposing here, sorry
from cpython.
OK, so we simply convert this code:
/*[clinic input]
os._path_normpath
path: object
Basic path normalization.
[clinic start generated code]*/
To this:
/*[clinic input]
os._path_normpath
/
path: object
Basic path normalization.
[clinic start generated code]*/
That's it. Oops, that's not supported:
Error in file 'Modules/posixmodule.c' on line 5473:
Function '_path_normpath' has an unsupported group configuration. (Unexpected state 0.d)
from cpython.
Well, I guess this can be closed then for the time being.
from cpython.
Related Issues (20)
- ``test_compile`` leaks references HOT 1
- `import keyword; help(keyword)` has some issues HOT 1
- _pydecimal.Decimal.__pow__ tries to compute 10**1000000000000000000 and thus doesn't terminate HOT 17
- Unittest not being found HOT 1
- When using inspect package's Parameter as dictionary keys, performance is lower compared to basic types, especially in large loops. HOT 1
- Don't needlessly repeat Sphinx directives HOT 17
- `dataclasses`: 3.12.3 regression with `weakref_slot` HOT 4
- CPython requires stdatomic.h HOT 2
- Call stats are incorrect for tier 2 and maybe for tier 1 as well HOT 1
- Problem with config cache of WASI HOT 11
- subclasses of telnetlib.Telnet may crash when used as context manager HOT 7
- Performance difference of C calling conventions HOT 1
- float('inf') faster ways HOT 10
- Python 3.x fails to load a .so file in TCL through tkinter HOT 1
- Python 3.x crashes when you load a .so file in TCL through tkinter HOT 6
- Add symlink to generalize macOS library pathname HOT 2
- The "finder" Glossary Entry May Need Updating
- Add option for hidden command line arguments to argparse HOT 1
- test_posixpath: test_expanduser_pwd2() fails on AMD64 Ubuntu Shared 3.x HOT 3
- [feature request] pathlib.Path().asyncopen HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpython.