Thanks to visit codestin.com
Credit goes to github.com

Skip to content

py/modsys: Implement sys.intern. #13123

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

Merged
merged 1 commit into from
Dec 15, 2023
Merged

Conversation

stinos
Copy link
Contributor

@stinos stinos commented Dec 4, 2023

See #6164 (comment) for backgroud; with the sys module now not being extensible anymore there's no other option than implementing this in C, as far as I can tell.

Copy link

github-actions bot commented Dec 4, 2023

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS

Copy link

codecov bot commented Dec 4, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (05d3b22) 98.40% compared to head (85c0216) 98.40%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #13123   +/-   ##
=======================================
  Coverage   98.40%   98.40%           
=======================================
  Files         159      159           
  Lines       21075    21075           
=======================================
  Hits        20738    20738           
  Misses        337      337           

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

@dpgeorge dpgeorge added the py-core Relates to py/ directory in source label Dec 14, 2023
py/mpconfig.h Outdated
@@ -1434,6 +1434,12 @@ typedef double mp_float_t;
#define MICROPY_PY_SYS_EXECUTABLE (0)
#endif

// Whether to provide "sys.identity", implemented simply as returning the argument passed
// since strings are already interned as qstr.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing this should say "sys.intern".

Also, not all strings are qstrs. We could actually implement this function by calling the existing mp_obj_str_intern_checked(). That has the benefit of raising an exception if the argument isn't a string (matching CPython).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing this should say "sys.intern".

Fixed.

Also, not all strings are qstrs. We could actually implement this function by calling the existing mp_obj_str_intern_checked()

Yeah was in doubt to use 'most strings are interned' but I missed the existence of that function, changed + added test

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment still needs fixing. Simply Whether to provide "sys.intern" would probably be enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Must have left my head at home today.

@dpgeorge dpgeorge added this to the release-1.22.0 milestone Dec 14, 2023
@stinos stinos force-pushed the sysintern branch 4 times, most recently from b02d6a2 to 5c2443e Compare December 14, 2023 13:34
@dpgeorge dpgeorge merged commit 85c0216 into micropython:master Dec 15, 2023
@stinos stinos deleted the sysintern branch January 8, 2024 09:09
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