Skip to content

Verify CircuitPython Behavior on Library import #10568

@TheKitty

Description

@TheKitty

CircuitPython version and board name

Any version

Code/REPL

example:

import adafruit_fruitjam

vs

from adafruit_fruitjam import peripherals

Behavior

I was asked to post this issue for CircuitPython core developers by @ladyada.

In the Adafruit Learning System Guide Memory-saving tips for CircuitPython
https://learn.adafruit.com/Memory-saving-tips-for-CircuitPython/optimizing-memory-use

By selectively importing only the functions you need, you may be able to reduce your memory usage versus importing a whole library. Each CircuitPython library is organized differently, so the impact of this technique will vary. Measure the memory use of the import to see how much memory is saved by using selective imports.

This behavior, per the feedback received is disputed allegedly by a Python core dev referenced in a stack overflow post: https://stackoverflow.com/questions/31691188/does-the-number-of-imported-modules-in-python-effect-memory-and-performance/31691438#31691438.

Ladyada has asked that the devs verify whether selective import from a module does indeed save memory or not and advise so that the guide may be updated accordingly.

Thank you for your time.

Description

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions