Search found 429 matches

by stijn
Sat Apr 04, 2020 8:42 am
Forum: General Discussion and Questions
Topic: Getting the size of an object in MicroPython
Replies: 7
Views: 133

Re: Getting the size of an object in MicroPython

list4 = array.array('H', (0 for _ in range(1000))) - takes 2092 bytes according to Python 3.7, 2336 bytes according to MicroPython. This seems consistent with the fact that Short datatype takes 2 bytes per member. Overhead is quite large, though, especially in MicroPython. Let's take this particula...
by stijn
Fri Apr 03, 2020 7:05 pm
Forum: General Discussion and Questions
Topic: Getting the size of an object in MicroPython
Replies: 7
Views: 133

Re: Getting the size of an object in MicroPython

Don't have time to write a complete reply now to explain where those numbers you see come from, but for starters whatever you test should not be on the REPL because the code and interpreting and compiling thereof itself also requires RAM. And at least you probably need collect() calls before the all...
by stijn
Fri Apr 03, 2020 2:11 pm
Forum: General Discussion and Questions
Topic: Getting the size of an object in MicroPython
Replies: 7
Views: 133

Re: Getting the size of an object in MicroPython

I don't know a solution but have a question: what do you want to know *exactly*, what do you want to do? 'The size of an object' is open for interpretion. Some comments: As you see, this list takes up 100 bytes. 1 byte per member, which sounds logical. Depends on how you look at it: I find it hard t...
by stijn
Sat Mar 28, 2020 1:02 pm
Forum: Programs, Libraries and Tools
Topic: Testing and mocking
Replies: 2
Views: 92

Re: Testing and mocking

Some previous discussion: viewtopic.php?f=2&t=7376
by stijn
Tue Mar 24, 2020 7:03 am
Forum: General Discussion and Questions
Topic: C Modules compiled as C++
Replies: 3
Views: 148

Re: C Modules compiled as C++

What Jimmo describes works, I've used things like that. You could also do (almost) everything in C++ including defining types etc, and then the .c module file just needs to forward a single call to populate the module globals to C++. A bit of a hack, but just to show there's more than one possibilit...
by stijn
Mon Mar 23, 2020 7:04 am
Forum: Programs, Libraries and Tools
Topic: CSV module devleopment
Replies: 10
Views: 305

Re: CSV module devleopment

@cr0mbly maybe you can start with adding the capability to just write CVS files. Even a subset of the CPython API would be quite useful. And it is rather easy in comparison with reading.
by stijn
Sun Mar 22, 2020 9:19 am
Forum: Programs, Libraries and Tools
Topic: CSV module devleopment
Replies: 10
Views: 305

Re: CSV module devleopment

Exactly. It's been unfortunately less than 1 year I had to work with CSV files and it's a terrible format to program with because it has no standard whatsoever, except something like "Stuff separated by this arbitrary separator which can be anything even though we call it 'comma-separated', but only...
by stijn
Tue Mar 17, 2020 3:14 pm
Forum: General Discussion and Questions
Topic: How to include a module
Replies: 11
Views: 1090

Re: How to include a module

Even though that works, I'd advice against it. Not just for the sake of doing 'the right thing' but mainly because it'll force you to learn Python and debugging techniques etc. It's lik the difference between trying random things until it works (not much learned), and investigating the problem follo...
by stijn
Mon Mar 16, 2020 8:16 am
Forum: General Discussion and Questions
Topic: Class destructor doesnt work in micropython?
Replies: 11
Views: 652

Re: Class destructor doesnt work in micropython?

I had similar issues when learning C# after having used mostly C++. While I still find the C++ 'automatic destruction on scope exit' way extremely handy, there are enough ways around it so I never found it to be a deal breaker in other languages.