Skip to content

Alternate fix for complex() parsing #17384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

jepler
Copy link
Contributor

@jepler jepler commented May 28, 2025

In contrast to #17383 this one also fixes parsing for complex("1 1j") where a sign character does not occur between the real and imaginary parts of a number with both parts. It almost certainly makes the code grow more. Please feel free to close this if the code growth isn't worth the benefit. If so, a section should probably be added to the difference page in the docs.

jepler and others added 3 commits May 28, 2025 20:40
Signed-off-by: Jeff Epler <jepler@gmail.com>
If a complex literal had a negative real part and a positive
complex part, it was not parsed properly.

Co-Authored-By: ComplexSymbol
 <141301057+ComplexSymbol@users.noreply.github.com>
Signed-off-by: Jeff Epler <jepler@gmail.com>
Signed-off-by: Jeff Epler <jepler@gmail.com>
Copy link

github-actions bot commented May 28, 2025

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:   -32 -0.004% standard
      stm32:   +24 +0.006% PYBV10
     mimxrt:   +32 +0.009% TEENSY40
        rp2:   +40 +0.004% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:   +26 +0.006% VIRT_RV32

Copy link

codecov bot commented May 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.54%. Comparing base (2dada06) to head (e8d0098).
Report is 65 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #17384   +/-   ##
=======================================
  Coverage   98.54%   98.54%           
=======================================
  Files         169      169           
  Lines       21898    21903    +5     
=======================================
+ Hits        21579    21584    +5     
  Misses        319      319           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dpgeorge
Copy link
Member

When the CI passes, let's see how big the code size change is.

A sign character is now required when a literal passed to
complex() has both a real and imaginary part.

Signed-off-by: Jeff Epler <jepler@gmail.com>
@jepler jepler force-pushed the complex-sign-number-alt branch from 64ddc9f to e8d0098 Compare May 29, 2025 06:08
@jepler
Copy link
Contributor Author

jepler commented May 29, 2025

Updated. I have seen this technique used but since I didn't see a diagnostic on the unix build (which allows it as an extension) I didn't realize it was needed here.

Future gcc will have a way to enable a diagnostic about this incorrect label usage even when not running in pedantic mode: https://gcc.gnu.org/pipermail/gcc-patches/2024-November/669243.html

@jepler jepler requested a review from dpgeorge May 29, 2025 06:09
@dpgeorge dpgeorge added the py-core Relates to py/ directory in source label Jun 4, 2025
@dpgeorge
Copy link
Member

Thanks for opening this for a comparison with #17383. Considering the relatively large increase in code size, I'll close this in favour of #17383.

At least with this PR, complex("1 1j") isn't supposed to be a correct number, so it's not like MicroPython is giving back an unexpectedly incorrect result (unlike complex("-1+1j") which was clearly wrong).

@dpgeorge dpgeorge closed this Jun 10, 2025
@jepler
Copy link
Contributor Author

jepler commented Jun 10, 2025

Makes perfect sense, thanks!

jepler added a commit to jepler/circuitpython that referenced this pull request Jun 10, 2025
In micropython#17384 it was
decided that fixing this difference was not worth the code size
increase.
jepler added a commit to jepler/circuitpython that referenced this pull request Jun 10, 2025
In micropython#17384 it was
decided that fixing this difference was not worth the code size
increase.
jepler added a commit to jepler/circuitpython that referenced this pull request Jun 10, 2025
In micropython#17384 it was
decided that fixing this difference was not worth the code size
increase.

Signed-off-by: Jeff Epler <jepler@gmail.com>
jepler added a commit to jepler/circuitpython that referenced this pull request Jun 16, 2025
In micropython#17384 it was
decided that fixing this difference was not worth the code size
increase.

Signed-off-by: Jeff Epler <jepler@gmail.com>
dpgeorge pushed a commit that referenced this pull request Jun 16, 2025
In #17384 it was decided that fixing this difference was not worth the code
size increase.  So document it instead.

Signed-off-by: Jeff Epler <jepler@gmail.com>
Josverl pushed a commit to Josverl/micropython that referenced this pull request Jun 19, 2025
In micropython#17384 it was decided that fixing this difference was not worth the code
size increase.  So document it instead.

Signed-off-by: Jeff Epler <jepler@gmail.com>
aivarannamaa pushed a commit to progering/micropython that referenced this pull request Jul 9, 2025
In micropython#17384 it was decided that fixing this difference was not worth the code
size increase.  So document it instead.

Signed-off-by: Jeff Epler <jepler@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
py-core Relates to py/ directory in source
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy