Search found 2981 matches

by pythoncoder
Sun Oct 21, 2018 9:31 am
Forum: General Discussion and Questions
Topic: re.sub regex won't match
Replies: 10
Views: 170

Re: re.sub regex won't match

So (correct me if I'm wrong) the take-home from this is that ure has a limitation by design. In CPython and MicroPython the string r'\n' contains two characters, '\' and 'n' . CPython's re module interprets these as a '\n' character while ure treats them literally. I guess in most cases the workroun...
by pythoncoder
Sat Oct 20, 2018 6:51 am
Forum: General Discussion and Questions
Topic: a question about const(..)
Replies: 5
Views: 98

Re: a question about const(..)

Looking at the bytecode on the Unix build c = const(x+y) produces the expected 50 LOAD_CONST_SMALL_INT 1100 53 LOAD_NAME z (cache=0) 57 BINARY_OP 1 __gt__ 58 POP_JUMP_IF_TRUE 41 whereas c = x + y produces a name lookup: 50 LOAD_NAME c (cache=0) 54 LOAD_NAME z (cache=0) 58 BINARY_OP 1 __gt__ 59 POP_J...
by pythoncoder
Fri Oct 19, 2018 8:52 am
Forum: General Discussion and Questions
Topic: Function with variable parameters in viper emitter
Replies: 2
Views: 48

You don't need Viper

You can address memory directly without using Viper. See recent discussions of the uctypes module, for example this thread.
by pythoncoder
Fri Oct 19, 2018 8:48 am
Forum: General Discussion and Questions
Topic: How to allocate a buffer that won't move around in memory?
Replies: 9
Views: 190

Consider the intended use cases

I think some consideration should be given to the principal use cases for MicroPython: embedded systems. Such systems typically run a do-forever loop. They are often highly time critical. They run on bare metal and are written by programmers with an understanding of hardware; they are prepared to ma...
by pythoncoder
Thu Oct 18, 2018 5:23 am
Forum: General Discussion and Questions
Topic: best way to store datestamps in upython
Replies: 4
Views: 99

Re: best way to store datestamps in upython

Looks fine to me :D As a general point when doing file operations it's best to use a context manager. This guarantees that the file will be closed even if an exception occurs: with open('/sd/data.txt', 'a') as f: f.write(data) # possible other file operations uos.umountsd() # The file is closed now ...
by pythoncoder
Wed Oct 17, 2018 4:08 pm
Forum: General Discussion and Questions
Topic: best way to store datestamps in upython
Replies: 4
Views: 99

Re: best way to store datestamps in upython

A practical consideration is how you want to access the file and whether you want it to be human-readable. If the file is only going to be read by code, writing the data as integers to a binary file is simple, efficient in time and file size, and enables random access. For a human-readable file I'd ...
by pythoncoder
Wed Oct 17, 2018 5:58 am
Forum: ESP32 boards
Topic: Differences between Micropython ports for ESP32 and ESP8266
Replies: 23
Views: 7477

Re: The pyb module

... I like the idea of an exception being raised if the feature doesn't exist on that port. That way code is portable and if u try to use a feature the hardware doesn't have then u get an exception. I think this makes sense too. Peter, do you have an opinion? ... It's a good idea. As is documenting...
by pythoncoder
Tue Oct 16, 2018 5:59 pm
Forum: Drivers for External Components
Topic: TinyRTC I2C Module DS1307 + AT24C32N
Replies: 13
Views: 563

Re: bizarre circuit design

I guess the diode protects against a reverse-fitted battery. What a revolting way to do it. :!:

R5 only makes sense if they have shares in a battery manufacturer.
by pythoncoder
Tue Oct 16, 2018 5:45 pm
Forum: General Discussion and Questions
Topic: Allocation when slicing memoryview instance
Replies: 5
Views: 85

Re: Allocation when slicing memoryview instance

Indeed. It does seem unfortunate that memoryview objects in particular use the heap. I have raised this RFC with a minimal test case. I'll be interested to see the response.