Search found 735 matches

by stijn
Sun Jun 12, 2022 7:11 am
Forum: General Discussion and Questions
Topic: Embedding MicroPython in a text editor
Replies: 3
Views: 1064

Re: Embedding MicroPython in a text editor

Does that sound right? Yes that's also basically how most ports' main() function works Wrt string memory, the takeaway is: it's not owned by the caller, and it lives as long as needed. Depends on a couple of things (object representation, whether it's an interned string or not) how this works inter...
by stijn
Wed Jun 08, 2022 8:53 am
Forum: General Discussion and Questions
Topic: Trying to understand how memory allocation is working here...
Replies: 10
Views: 3805

Re: Trying to understand how memory allocation is working here...

pythoncoder wrote:
Wed Jun 08, 2022 8:41 am
it seems to be something to do with the REPL
Yes that's it, displaying on REPL allocates strings. Potentially also Thonny adds some. In any case, for measuting memroy-related behavior in an application one cannot rely on what the REPL says.
by stijn
Mon May 30, 2022 6:42 am
Forum: General Discussion and Questions
Topic: C++ module New/Delete and math and C libraries
Replies: 1
Views: 846

Re: C++ module New/Delete and math and C libraries

I think what you're doing would work. Only way to make sure is write tests and/or run your application enough times. First question though is whether it is needed: if the object created by new isn't actually going to be used by MicroPython itself, you can just allocate it from the normal C++ heap (w...
by stijn
Mon May 16, 2022 8:20 am
Forum: General Discussion and Questions
Topic: track program execution
Replies: 2
Views: 967

Re: track program execution

If you build with MICROPY_PY_SYS_SETTRACE defined (e.g. make CFLAGS_EXTRA="-DMICROPY_PY_SYS_SETTRACE=1") the sys.settrace (https://docs.python.org/3/library/sys.html#sys.settrace) functionality becomes available. Not completely the same as the trace module, but does track all calls. You can use the ...
by stijn
Sun May 15, 2022 4:20 pm
Forum: Development of MicroPython
Topic: Valgrind reporting memory leak with dynamic heap
Replies: 1
Views: 1309

Re: Valgrind reporting memory leak with dynamic heap

There's a malloc() for mp_heap but code shows no call to free(), hence it's a leak? That, or valgrind is incorrectly reporting the static memory as leaked.
by stijn
Sun May 15, 2022 4:18 pm
Forum: General Discussion and Questions
Topic: RFC: How to Test MicroPython
Replies: 8
Views: 2487

Re: RFC: How to Test MicroPython

# replace some libs with their c-python 'equivalents' sys.modules['uasyncio'] = __import__('asyncio') ... Perhaps you're aware already, but a while ago MicroPython impleneted 'automatic discovery' of any module prefixed with a u, so the idea is all code simply can do 'import asyncio' as usual and i...
by stijn
Mon May 09, 2022 2:08 pm
Forum: General Discussion and Questions
Topic: Viewing all class variables created within class instance
Replies: 6
Views: 2420

Re: Viewing all class variables created within class instance

For completeness the difference is this: class Foo: x = 0 def __init__(self, y): self.y = 0 print(dir(Foo)) print(dir(Foo(1))) output: ['__class__', '__init__', '__module__', '__name__', '__qualname__', '__bases__', '__dict__', 'x'] ['__class__', '__init__', '__module__', '__qualname__', '__dict__',...
by stijn
Mon May 09, 2022 2:03 pm
Forum: General Discussion and Questions
Topic: Viewing all class variables created within class instance
Replies: 6
Views: 2420

Re: Viewing all class variables created within class instance

Without the brackets after ADC, you are not creating an instance of the class i.e. not calling the constructor. Your first attempt was correct, but you have to supply arguments (as the error says), sorry but I left that out in my sample because i don't know them by heart plus they might be different...
by stijn
Mon May 09, 2022 5:57 am
Forum: General Discussion and Questions
Topic: Viewing all class variables created within class instance
Replies: 6
Views: 2420

Re: Viewing all class variables created within class instance

Call dir() on your instance, not on the class itself. Like

Code: Select all

a = machine.ADC()
dir(a)
by stijn
Thu May 05, 2022 8:42 am
Forum: ESP32 boards
Topic: reload python script
Replies: 3
Views: 3199

Re: reload python script

What error?