Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

pow() docs shouldn't require numeric arguments #130102

Open
Assignees
skirpichev
Labels
docsDocumentation in the Doc dir
@skirpichev

Description

@skirpichev

Currently, the second paragraph ofdocs starts with "The arguments must have numeric types." That seems to be too restrictive and many third-party packages already break this rule. E.g. SymPy support arbitrary symbolic expressions:

In [1]: pow(x, y)Out[1]:  yx In [2]: pow(x, y, z)Out[2]:  y      x  mod z

Diofant also uses both forms for polynomial arithmetic:

In [1]: R, x = ring('x', QQ)In [2]: pow(x + 1, 7, 2*x**2 - 1)Out[2]: 239/8*x + 169/8In [3]: ((x + 1)**7) % (2*x**2 - 1)Out[3]: 239/8*x + 169/8In [4]: (x + 1)**2Out[4]: x**2 + 2*x + 1In [5]: pow(x + 1, 2)Out[5]: x**2 + 2*x + 1

I suggest to drop this requirement. In fact, first paragraph already mention equivalents for two-arg and three-arg versions of the pow(). We can rephrase it like this: "Return base to the power exp, an equivalent tobase**exp; if mod is present, return base to the power exp, modulo mod, an equivalent to(base**exp) % mod (but computed more efficiently)."

The third paragraph also might instead specify requirements for the mod in case ofinteger base and exponent, not just for builtin int's.

Metadata

Metadata

Assignees

Labels

docsDocumentation in the Doc dir

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp