peps icon indicating copy to clipboard operation
peps copied to clipboard

PEP 812: Imaginary type and IEC 60559-compatible complex arithmetic

Open skirpichev opened this issue 2 months ago • 6 comments

Basic requirements (all PEP Types)

  • [x] Read and followed PEP 1 & PEP 12
  • [x] File created from the latest PEP template
  • [x] PEP has next available number, & set in filename (pep-NNNN.rst), PR title (PEP 123: <Title of PEP>) and PEP header
  • [x] Title clearly, accurately and concisely describes the content in 79 characters or less
  • [ ] Core dev/PEP editor listed as Author or Sponsor, and formally confirmed their approval
  • [x] Author, Status (Draft), Type and Created headers filled out correctly
  • [ ] PEP-Delegate, Topic, Requires and Replaces headers completed if appropriate
  • [ ] Required sections included
    • [x] Abstract (first section)
    • [x] Copyright (last section; exact wording from template required)
  • [x] Code is well-formatted (PEP 7/PEP 8) and is in code blocks, with the right lexer names if non-Python
  • [x] PEP builds with no warnings, pre-commit checks pass and content displays as intended in the rendered HTML
  • [x] Authors/sponsor added to .github/CODEOWNERS for the PEP

Standards Track requirements

  • [x] PEP topic discussed in a suitable venue with general agreement that a PEP is appropriate
  • [x] Suggested sections included (unless not applicable)
    • [x] Motivation
    • [x] Rationale
    • [x] Specification
    • [x] Backwards Compatibility
    • [ ] Security Implications
    • [x] How to Teach This
    • [x] Reference Implementation
    • [x] Rejected Ideas
    • [x] Open Issues
  • [x] Python-Version set to valid (pre-beta) future Python version, if relevant
  • [ ] Any project stated in the PEP as supporting/endorsing/benefiting from the PEP formally confirmed such
  • [ ] Right before or after initial merging, PEP discussion thread created and linked to in Discussions-To and Post-History

📚 Documentation preview 📚: https://pep-previews--4681.org.readthedocs.build/

https://pep-previews--4681.org.readthedocs.build/pep-0812/

skirpichev avatar Oct 31 '25 06:10 skirpichev

Based on feedback from the latest discussion thread, I hope @serhiy-storchaka might sponsor this.

CC @serhiy-storchaka CC @mdickinson

(Alternative formatting with mathjax)

N.B. I did local builds with the default sphinx config and it seems, that "math" directives are rendered odd with the "maths_to_html". In particular, equation numbering is lost (though, references to equations are kept). Any way to fixing this without replacing "math" with something else? CC @AA-Turner Locally I've something like this: Screenshot from 2025-10-31 09-18-03

skirpichev avatar Oct 31 '25 06:10 skirpichev

Please review PEP 1.

The general order of things:

  1. Open a discussion to see if there is consensus for this idea. This is also to save you time in case the idea is rejected.
  2. During the discussion, find a sponsor.
  3. Work with your sponsor, and when they think the PEP is ready for submission, then open the PR.
  4. A PEP number is assigned by a PEP editor after the sponsor has confirmed their sponsorship.

Therefore please don't write and submit a PEP with just a hope someone will sponsor. This should be arranged beforehand.

hugovk avatar Oct 31 '25 06:10 hugovk

Ok, sorry.

skirpichev avatar Oct 31 '25 06:10 skirpichev

Work with your sponsor, and when they think the PEP is ready for submission, then open the PR.

Well, maybe now is time? // https://discuss.python.org/t/77073/20

skirpichev avatar Oct 31 '25 10:10 skirpichev

@hugovk, may I reserve some number and set CODEOWNERS?

Outdated

BTW, it seems that "math" directive isn't used so much in peps/ and mostly for inline math:

peps/pep-0465.rst:.. math::
peps/pep-0465.rst:of :math:`H \beta - r` should perhaps be factored out; and,
peps/pep-0465.rst::math:`\cdot`, and has Perl/PHP baggage.  ``$`` is probably the
peps/pep-0465.rst:* It's round like ``*`` and :math:`\cdot`.
peps/pep-0465.rst:users have an intuition that an expression like :math:`R S x` proceeds
peps/pep-0465.rst:from right-to-left, with first :math:`S` transforming the vector
peps/pep-0465.rst::math:`x`, and then :math:`R` transforming the result. This isn't
peps/pep-0465.rst:intuition is more common than for other operations like :math:`2 \cdot
peps/pep-0465.rst:.. [#lht] In this formula, :math:`\beta` is a vector or matrix of
peps/pep-0465.rst:   regression coefficients, :math:`V` is the estimated
peps/pep-0465.rst:   test the null hypothesis that :math:`H\beta = r`; a large :math:`S`
peps/pep-0465.rst:   example, in an analysis of human height, the vector :math:`\beta`
peps/pep-0465.rst:   measured women, and then setting :math:`H = [1, -1], r = 0` would
peps/pep-0724.rst:NP is ..     :math:`R`               :math:`A \land R`
peps/pep-0724.rst:NN is ..     :math:`A`               :math:`A \land \neg{R}`
peps/pep-0742.rst:Formally, type *NP* should be narrowed to :math:`A \land R`,
peps/pep-0742.rst::math:`A \land \neg R`, the intersection of *A* and the complement of *R*.
peps/pep-0802.rst:This is modelled after the corresponding mathematical symbol ':math:`\emptyset`'.
peps/pep-0802.rst:notation for the empty set, :math:`\emptyset`.
peps/pep-0802.rst:for the empty set (':math:`\emptyset`').
peps/pep-0802.rst:The authors prefer ``{/}`` due to the resemblance to :math:`\emptyset`.

Should I reformat equations with some other markup?

skirpichev avatar Oct 31 '25 11:10 skirpichev

@hugovk, may I reserve some number and set CODEOWNERS?

Yes, you may use 812. Thanks!

hugovk avatar Nov 01 '25 10:11 hugovk

@serhiy-storchaka, I hope now this ready for your review.

~~Perhaps, the major remaining question is: should we try to introduce the imaginary builtin from beginning? Current version don't do so (it's in Open Issues), but maybe this should be reverted? If we introduce a new builtin - this PEP can discuss parsing of strings, which it will accept.~~

skirpichev avatar Nov 06 '25 02:11 skirpichev