Skip to content

Fix shift right in displayio.Group #1740

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
Apr 3, 2019

Conversation

caternuson
Copy link

Fix for #1739. Just a change of direction. Checks out:

Adafruit CircuitPython 4.0.0-beta.6-22-g19278e028-dirty on 2019-04-03; Adafruit PyPortal with samd51j20
>>> import board, displayio
>>> from adafruit_display_shapes.circle import Circle
>>> group = displayio.Group(max_size=10)
>>> board.DISPLAY.show(group)
>>> circle1 = Circle(30, 30, 5, outline=0xFFFFFF) ; group.append(circle1)
>>> circle2 = Circle(50, 30, 10, outline=0xFFFFFF) ; group.append(circle2)
>>> circle3 = Circle(100, 100, 20, outline=0xFFFFFF) ; group.append(circle3)
>>> circle4 = Circle(200, 100, 30, outline=0xFFFFFF) ; group.append(circle4)
>>> group[0]
<Circle object at 20003390>
>>> group[1]
<Circle object at 200035d0>
>>> group[2]
<Circle object at 200035b0>
>>> group[3]
<Circle object at 200038a0>
>>> circle_foo = Circle(100, 150, 10, outline=0xFFFFFF)
>>> group.insert(1, circle_foo)
>>> group[0]
<Circle object at 20003390>
>>> group[1]
<Circle object at 20005ea0>
>>> group[2]
<Circle object at 200035d0>
>>> group[3]
<Circle object at 200035b0>
>>> group[4]
<Circle object at 200038a0>
>>> 

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.

Thank you for both discovering and fixing this!

@tannewt tannewt merged commit 9bfa625 into adafruit:master Apr 3, 2019
jepler pushed a commit to jepler/circuitpython that referenced this pull request Mar 6, 2020
This commit implements automatic module weak links for all built-in
modules, by searching for "ufoo" in the built-in module list if "foo"
cannot be found.  This means that all modules named "ufoo" are always
available as "foo".  Also, a port can no longer add any other weak links,
which makes strict the definition of a weak link.

It saves some code size (about 100-200 bytes) on ports that previously had
lots of weak links.

Some changes from the previous behaviour:
- It doesn't intern the non-u module names (eg "foo" is not interned),
  which saves code size, but will mean that "import foo" creates a new qstr
  (namely "foo") in RAM (unless the importing module is frozen).
- help('modules') no longer lists non-u module names, only the u-variants;
  this reduces duplication in the help listing.

Weak links are effectively the same as having a set of symbolic links on
the filesystem that is searched last.  So an "import foo" will search
built-in modules first, then all paths in sys.path, then weak links last,
importing "ufoo" if it exists.  Thus a file called "foo.py" somewhere in
sys.path will still have precedence over the weak link of "foo" to "ufoo".

See issues: adafruit#1740, adafruit#4449, adafruit#5229, adafruit#5241.
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.

2 participants