Skip to content

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

Merged
tannewt merged 2 commits into
adafruit:masterfrom
dhalbert:3.0_consistent_features
Jan 17, 2018
Merged

tannewt merged 2 commits into
adafruit:masterfrom
dhalbert:3.0_consistent_features

Conversation

@dhalbert

@dhalbert dhalbert commented Jan 10, 2018 •

Copy link
Copy Markdown
Collaborator
  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

jerryneedell commented Jan 10, 2018 •

Copy link
Copy Markdown
Collaborator

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

@dhalbert

Copy link
Copy Markdown
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
Copy Markdown
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

tannewt commented Jan 14, 2018

Copy link
Copy Markdown
Member

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
Copy Markdown

@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
Copy Markdown
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

jerryneedell commented Jan 16, 2018 •

Copy link
Copy Markdown
Collaborator

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

dhalbert commented Jan 17, 2018 •

Copy link
Copy Markdown
Collaborator Author

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.

@tannewt tannewt left a comment

Copy link
Copy Markdown
Member

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