Git Product home page Git Product logo

Comments (14)

AlexWaygood avatar AlexWaygood commented on June 12, 2024 4

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.

nineteendo avatar nineteendo commented on June 12, 2024 2

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.

AlexWaygood avatar AlexWaygood commented on June 12, 2024 1

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.

erlend-aasland avatar erlend-aasland commented on June 12, 2024 1

This would break a lot of code. I don't think this is a good idea.

from cpython.

AlexWaygood avatar AlexWaygood commented on June 12, 2024 1

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.

nineteendo avatar nineteendo commented on June 12, 2024

cc @erlend-aasland, @eendebakpt

from cpython.

nineteendo avatar nineteendo commented on June 12, 2024

Alex, you should probably also add the performance label, as this could greatly improve CPython's performance. :)

from cpython.

nineteendo avatar nineteendo commented on June 12, 2024

Damn that's really unfortunate. ;( Could we do this deprecation as soon as possible with a list of all affected functions?

from cpython.

nineteendo avatar nineteendo commented on June 12, 2024

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.

nineteendo avatar nineteendo commented on June 12, 2024

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.

nineteendo avatar nineteendo commented on June 12, 2024

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.

AlexWaygood avatar AlexWaygood commented on June 12, 2024

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.

nineteendo avatar nineteendo commented on June 12, 2024

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.

nineteendo avatar nineteendo commented on June 12, 2024

Well, I guess this can be closed then for the time being.

from cpython.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.