-
Notifications
You must be signed in to change notification settings - Fork 23
Do you prefer a lookup table or an algorithm? + duplicate code #43
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
Comments
I much prefer the table. You could make it even more compact and faster by turning it into a To prevent pylint from complaining about duplicate code, or anything in particular, you should be able to do a |
Previously @ladyada said: "please at least make this a tuple, or a bytearray, - at best please algorithize as this table will take up valuable ram on small devices": #26 (comment) I guess I did not get the "tuple" nor the "bytearray" part of the answer and went algorithm... and that was a nightmare result. I'll give this another try and pylint will not detect that as duplicate. |
bytes or bytearrays are the smallest option because they won't have tuple overhead and every element will be 1 byte instead of 4 like all Python objects are. |
I want to write the code for Pimoroni 5x5 LED Matrix. The table and algorithm is very similar is for led_shim.
Except that led_shim has 28 entries and 5x5 has 25 entries.
Q1: What is prefered way of writing the mapping
Adafruit_CircuitPython_IS31FL3731/adafruit_is31fl3731/keybow2040.py
Line 65 in 11533d4
Adafruit_CircuitPython_IS31FL3731/adafruit_is31fl3731/led_shim.py
Line 62 in 11533d4
(see below for code extract)
Q2: How do I convince pylint that this duplicate code is OK? Or should I put the table/algo in a separate file and import? (it is very similar but maybe with 3 entries less, but having 3 extra entries is not hurting much.
Lookup used in keybow2040:
Algorithm used in led_shim (not exactly the same table):
The text was updated successfully, but these errors were encountered: