Search found 735 matches

by stijn
Mon Sep 26, 2022 6:44 am
Forum: Announcements and News
Topic: Migration to GitHub Discussions
Replies: 20
Views: 154133

Re: Migration to GitHub Discussions

First time users of Micropython Github will probably be unsure how to or where to ask, and how to appropriately format py code... And having first time users having to go off tangent and do research on using Github Discussions might in some instances be off putting to some and choose not engage...?...
by stijn
Tue Aug 16, 2022 6:41 am
Forum: General Discussion and Questions
Topic: Easy way to emulate str 'capitalize' function?
Replies: 4
Views: 4493

Re: Easy way to emulate str 'capitalize' function?

Something like s[0].upper() + s[1:] ? Or are you asking how to add this to micropython?
by stijn
Thu Aug 11, 2022 9:52 am
Forum: General Discussion and Questions
Topic: Frustrations with missing libraries?
Replies: 18
Views: 21292

Re: Frustrations with missing libraries?

if solution developers (i.e. MicroPython) are not engaged in the forum That is not really the case though: most of the people having contributed to micropython on Github also have and still do here. But this is all about volunteering so one cannot expect every single question to be seen/answered. M...
by stijn
Sun Jul 03, 2022 10:47 am
Forum: Programs, Libraries and Tools
Topic: JSON serialisation
Replies: 5
Views: 3344

Re: JSON serialisation

Change your class so the members have the exact same name as the arguments, then use __dict__ : class ToDoItem: def __init__(self, name, description, isComplete): self.name = name self.description = description self.isComplete = isComplete import json toSerialize = ToDoItem('a', 'b', 'c') print(toSe...
by stijn
Thu Jun 16, 2022 10:01 am
Forum: General Discussion and Questions
Topic: The order of operations matters. A lot!
Replies: 12
Views: 7007

Re: The order of operations matters. A lot!

That's a 25% improvement just for counting down to zero. Ok, but the counting down compares using equality, the other one using less than. That's not the same as comparing wheher a == 0 is faster than a == 23 which is what we were discussing originally. I don't have time to write a complete portabl...
by stijn
Wed Jun 15, 2022 7:35 pm
Forum: General Discussion and Questions
Topic: The order of operations matters. A lot!
Replies: 12
Views: 7007

Re: The order of operations matters. A lot!

Another one that's interesting is checking for a specific value in a variable as opposed to zero. The zero check is faster because processors don't have to compare to anything, just load the value into a single register. So, a == 0 is faster than a == 23. The exception to that is if the "a" and "23...
by stijn
Wed Jun 15, 2022 6:34 am
Forum: General Discussion and Questions
Topic: os Vs uos rabbit hole
Replies: 6
Views: 3466

Re: os Vs uos rabbit hole

Hard to tell. I mean, I'd say 'this is an implementation detail and the key is in the source code' but I'm actually not sure. I also cannot reproduce it on the unix port for example. The 2 cases you describe differ in more than just .py vs .mpy. First one is 'run from IDE', not sure what that means ...
by stijn
Wed Jun 15, 2022 6:22 am
Forum: General Discussion and Questions
Topic: The order of operations matters. A lot!
Replies: 12
Views: 7007

Re: The order of operations matters. A lot!

Are you asking about short-circuiting boolean operators (https://docs.python.org/3/library/stdty ... and-or-not)? That's a potentially crucial difference with mereley changing order of code: it simply skips code.
by stijn
Tue Jun 14, 2022 3:11 pm
Forum: General Discussion and Questions
Topic: os Vs uos rabbit hole
Replies: 6
Views: 3466

Re: os Vs uos rabbit hole

So your code does

Code: Select all

import os
os.urandom
yet it fails saying uos isn't defined? Can you reproduce that with the minimal sample above? Sounds like a bug.