Skip to content

Added uschedule library#62

Closed
cognitivegears wants to merge 1 commit into
adafruit:masterfrom
cognitivegears:master
Closed

Added uschedule library#62
cognitivegears wants to merge 1 commit into
adafruit:masterfrom
cognitivegears:master

Conversation

@cognitivegears
Copy link
Copy Markdown
Contributor

Adding the CircuitPython_uschedule (https://github.com/cognitivegears/CircuitPython_uschedule) library, which is a version of schedule (https://pypi.org/project/schedule/) updated to work with CircuitPython. This library allows for the scheduling of functions in a flexible functional style. This is useful to avoid having to hand-code scheduling into a circuitpython project, especially in conjunction with RTCs and long-scheduled jobs. More information is available in the repo and readthedocs (https://circuitpython-uschedule.readthedocs.io).

@ladyada
Copy link
Copy Markdown
Member

ladyada commented Mar 27, 2021

hihi is uschedule a 'direct subset' of schedule? if it were, that would allow folks to develop matching code on CPython

@cognitivegears
Copy link
Copy Markdown
Contributor Author

cognitivegears commented Mar 27, 2021

hihi is uschedule a 'direct subset' of schedule? if it were, that would allow folks to develop matching code on CPython

It is! The API is fully compatible with schedule. The only changes at all were some features on the CPython version that were either not available or where I was worried about memory size by including (things that were not strictly necessary in any case). In those cases, the function signatures were left the same and the changes documented so that code is directly compatible between the versions in both directions.

@ladyada
Copy link
Copy Markdown
Member

ladyada commented Mar 27, 2021

woohoo thats great, we recommend naming it cognitivegears_schedule so folks can import cognitivegears_schedule as schedule -- only because folks tend to use u as a prefix when its not a proper subset, if that makes sense!

@cognitivegears
Copy link
Copy Markdown
Contributor Author

cognitivegears commented Mar 28, 2021

woohoo thats great, we recommend naming it cognitivegears_schedule so folks can import cognitivegears_schedule as schedule -- only because folks tend to use u as a prefix when its not a proper subset, if that makes sense!

Thanks @ladyada, will do. One question if you don't mind first though. Is the name "circuitpython_schedule" acceptable, or do we need to use our own names (like "cognitivegears_schedule"?) I feel like "circuitpython_schedule" might better reflect what the module does/intended audience when searching on pypi especially, but I'm happy to use your suggestion if that isn't appropriate.

@ladyada
Copy link
Copy Markdown
Member

ladyada commented Mar 28, 2021

thats ok too, we like to have the authorname in just in case someone else decides to make a library with a similar name (or, say forks yours...)

@tannewt
Copy link
Copy Markdown
Member

tannewt commented Mar 29, 2021

You may be able to save a little memory by using data descriptors for the weekday properties. data descriptors are handy for factoring out repeated property code. This primer is pretty good: https://docs.python.org/3/howto/descriptor.html

@cognitivegears
Copy link
Copy Markdown
Contributor Author

@tannewt I tried changing this out to data descriptors, but was not able to save any significant memory (the code size offset was larger than the savings.) I did find some other areas I could likely save however, but I'm saving this for a future release as I'd like to get this out there in the meantime. I've tested on the RPi pico, Adafruit RP2040 featherwing and the S2 featherwing so far successfully, so this is likely useful in the meantime, at least on bigger/more capable circuitpython boards.

@cognitivegears
Copy link
Copy Markdown
Contributor Author

All, I'm closing this and will open up a new PR with the updated module name. Thanks for all your help on this.

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.

3 participants