Skip to content

Make chosen features consistent across all boards and ports atmel-samd, esp8266, and nrf. #518

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 2 commits into from
Jan 17, 2018

Conversation

dhalbert
Copy link
Collaborator

@dhalbert dhalbert commented Jan 10, 2018

  1. Turn off MICROPY_CPYTHON_COMPAT, which includes a number of minor CPython compatibility features, most of which have workarounds, but uses up significant flash.
  2. Turn on MICROPY_PY_SYS_MAXSIZE, which implements sys.maxsize.
  3. Turn on MICROPY_CAN_OVERRIDE_BUILTINS, which implements "_" as the most recent value in the REPL, and also enables redefining builtins.

Fixes #384, #442, #480, respectively.

…d, esp8266, and nrf.

1. Turn off MICROPY_CPYTHON_COMPAT, which includes a number of minor CPython compatibility features,
most of which have workarounds, but uses up significant flash.
2. Turn on MICROPY_PY_SYS_MAXSIZE, which implements sys.maxsize.
3. Turn on MICROPY_CAN_OVERRIDE_BUILTINS, which implements "_" as the most recent value in the REPL,
and also enables redefining builtins.
@dhalbert dhalbert requested a review from tannewt January 10, 2018 01:50
@dhalbert dhalbert changed the title Make chosen features consistent across all boards and ports atmel-samdd, esp8266, and nrf. Make chosen features consistent across all boards and ports atmel-samd, esp8266, and nrf. Jan 10, 2018
@jerryneedell
Copy link
Collaborator

jerryneedell commented Jan 10, 2018

Do you also want to enable
#define MICROPY_ENABLE_SOURCE_LINE
in the nrf build?

@dhalbert
Copy link
Collaborator Author

@jerryneedell Good idea. I didn't do any kind of comprehensive look at what's different in nrf. If you know of anything else let me know.

@jerryneedell
Copy link
Collaborator

That is the one I usually add along with uncommenting out the BLE_MODULE and UBLUEPY_MODULE but I think Kevin wants this tested more before they are mainstreamed. I have been playing with them a little but happy to deal with them myself for now.

@tannewt
Copy link
Member

tannewt commented Jan 14, 2018

Do the workarounds for CPython compat still work in CPython? I don't want us teaching bad habits that break when moving to CPython.

@microbuilder
Copy link

@jerryneedell I'm hoping to put in a PR this week with BLE support enabled out of the box, but we migrated to a different version of the SD so I need to make sure there aren't any gotchas or breaking changes that aren't immediately visible.

@jerryneedell
Copy link
Collaborator

@microbuilder Thanks. So far, I have tried enabling BLE with the current version and executed the ubluepy_scan and the ubluepy_eddystone examples.

@jerryneedell
Copy link
Collaborator

jerryneedell commented Jan 16, 2018

I added the 2 proposed changes to the feather52 mpconfigport.h ( with PR #528 as well)

#define MICROPY_ENABLE_SOURCE_LINE (1)
#define MICROPY_CPYTHON_COMPAT (0)

The build compiles OK and I have not seen any adverse impact.
The code size is reduced by 512 bytes.
The Source line does show up in the REPL for Exception Tracebacks - nice!

Are there specific things to try to test turning off the CPYTHON_COMPAT ?

@tannewt tannewt added this to the 3.0 Beta milestone Jan 16, 2018
@dhalbert
Copy link
Collaborator Author

dhalbert commented Jan 17, 2018

Are there specific things to try to test turning off the CPYTHON_COMPAT ?

MICROPY_CPYTHON_COMPAT enables:

  • TextIOWrapper
  • namedtuple("MyTuple", ("id name")) in addition to namedtuple("MyTuple", ("id", "name")) -- parsed string in addition to sequence for tuple names
  • print(f) prints <function f at 0x20001220> instead of just <function>
  • str() and bytes() with encoding arg (encoding as a keyword arg is not implemented in any case)
  • decode() and encode() (workaround is to use str() and bytes())
  • StringIO acting more like a file (closable, otherwise the underlying string is just empty)
  • someobject.__dict__
  • type(someobject).__name__
  • close(file_descriptor) is a little different
  • __main__ refers to module that was loaded by command-line -m switch (not relevant to bare-metal ports, I think)
  • delattr() available
  • object.__dict__ (The actual object class)
  • enumerate() can take iterable and start args

As you can see most of these are edge cases for language consistency.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Ok, sounds like things will be a subset which is good.

@tannewt tannewt merged commit 23eb79c into adafruit:master Jan 17, 2018
@dhalbert dhalbert deleted the 3.0_consistent_features branch January 17, 2018 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants