GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Missing "/" in function signatures of the rst docs of stdlib (e.g. the math module) · Issue #101118 · python/cpython

Missing "/" in function signatures of the rst docs of stdlib (e.g. the math module) #101118

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Missing "/" in function signatures of the rst docs of stdlib (e.g. the math module)#101118
Copy link
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir

Description

@skirpichev
skirpichev
opened on Jan 18, 2023
Issue body actions

after PEP 570, there is a syntax to specify positional-only parameters in the function definition. Unfortunately, most stdlib modules ignore this (the os module seems to be an exception). The math module is an example. While

>>> inspect.signature(math.ceil)
<Signature (x, /)>

the module docs display the function signature as math.ceil(x), that is wrong:

>>> math.ceil(x=3.14)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: math.ceil() takes no keyword arguments

Linked PRs

  • gh-101118: correct function signatures in the math module docs #101120

Activity

  1. skirpichev
    added
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    on Jan 18, 2023
  2. rhettinger
    closed this as not plannedon Jan 18, 2023
  3. skirpichev commented on Jul 19, 2024

    @skirpichev
    skirpichev
    on Jul 19, 2024
    MemberAuthor
    More actions

    @sobolevn, @rhettinger - now Python Documentation Editorial Board decided to specify positional-only arguments, see docs:
    "If a function accepts positional-only or keyword-only arguments, include the slash and the star in the signature as appropriate" (c)

    Either this issue (and linked pr) should be reopened - or this decision reverted, see d.p.o thread with announce.

  4. skirpichev commented on Jul 21, 2024

    @skirpichev
    skirpichev
    on Jul 21, 2024
    MemberAuthor
    More actions

    BTW, we can avoid this funny notation (at least for modules with simple interfaces like math or cmath), while preserving "precision and completeness" of reference docs.

    Here tests for positional-or-keyword in the cmath:

    $ python -m pyperf timeit -s 'from cmath import acos;z=2' -q 'acos(z)'  # (1)
    Mean +- std dev: 497 ns +- 10 ns
    $ python -m pyperf timeit -s 'from cmath import acos;z=2' -q 'acos(z=z)'
    Mean +- std dev: 625 ns +- 31 ns
    

    vs positional-only (in main):

    $ python -m pyperf timeit -s 'from cmath import acos;z=2' -q 'acos(z)'  # (2)
    Mean +- std dev: 485 ns +- 6 ns
    

    Overhead for arguments processing in (1) is measurable, but it's 2-3% of timings in (2). Maybe it's acceptable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dirDocumentation in the Doc dir

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.