Search found 463 matches
- Wed Nov 25, 2015 4:51 pm
- Forum: Programs, Libraries and Tools
- Topic: uasyncio - asyncio-like cooperative multitasking framework for uPy
- Replies: 114
- Views: 134474
Re: asyncio-like cooperative multitasking framework for uPy
So, based on the analysis above, I can propose different ways to solve it: 1. [...] 4. We change function signature of .add_reader() and friends - instead of accepting "file descriptor", as CPython asyncio mandates, it would accept "file-like object", and .add_reader() can decide what to do with it...
- Sun Nov 22, 2015 1:35 am
- Forum: General Discussion and Questions
- Topic: Bad performance of micropython vs CPython at string padding
- Replies: 6
- Views: 5704
Re: Bad performance of micropython vs CPython at string padding
Interesting. But change "utf-8" to something else and pass sth other than 0-bytes and Micropython will give wrong results.pfalcon wrote:For completeness, here's testcase which is almost 10,000 times slower on CPython:
- Sun Nov 22, 2015 1:18 am
- Forum: General Discussion and Questions
- Topic: Bad performance of micropython vs CPython at string padding
- Replies: 6
- Views: 5704
Re: Bad performance of micropython vs CPython at string padding
That would also explain the performance improvement of pad3 over pad2. len(s) seems relatively costly.
But AFAIK Python 3.5 uses a variable-byte internal string representation now as well (but not utf-8).
But AFAIK Python 3.5 uses a variable-byte internal string representation now as well (but not utf-8).
- Sun Nov 22, 2015 12:33 am
- Forum: General Discussion and Questions
- Topic: Bad performance of micropython vs CPython at string padding
- Replies: 6
- Views: 5704
Re: Bad performance of micropython vs CPython at string padding
Beyond that, your test contain logical error which of course affect results. String is a sequence of characters. It makes no sense to pad it for 4-bytes alignment - you cannot assume anything about "byte size" of characters. The original functions I based my test script on were receiving a str and ...
- Sat Nov 21, 2015 11:48 pm
- Forum: General Discussion and Questions
- Topic: Bad performance of micropython vs CPython at string padding
- Replies: 6
- Views: 5704
Bad performance of micropython vs CPython at string padding
I was profiling some different functions for padding binary strings with zeros for a 4-byte alignment and I noticed that micropython (unix) performs really badly compared to CPython (let alone PyPy) at this. For comparison, I also timed a simple numerical function (fibonacci) and you can see that mi...
- Fri Nov 20, 2015 4:29 pm
- Forum: Programs, Libraries and Tools
- Topic: usocket UDP and sockaddr questions
- Replies: 16
- Views: 17704
Re: usocket UDP and sockaddr questions
This seems to tell otherwise:pfalcon wrote:bytes is immutable object, so it's only suitable for read-only arguments, which won't be changed. bytearray is mutable, and is suitable for buffers which will be written to.
https://github.com/micropython/micropyt ... /re.py#L68
- Fri Nov 20, 2015 4:15 pm
- Forum: Programs, Libraries and Tools
- Topic: usocket UDP and sockaddr questions
- Replies: 16
- Views: 17704
Re: usocket UDP and sockaddr questions
So, I eventually figured out inet_ntop : import socket import struct INET_ADDRSTRLEN = 16 inet_ntop = getattr(socket, 'inet_ntop', None) if not inet_ntop: import ffilib _inet_ntop = ffilib.libc().func("s", "inet_ntop", "iPpi") def inet_ntop(a): buf = bytearray(INET_ADDRSTRLEN) res = _inet_ntop(socke...
- Fri Nov 20, 2015 4:01 pm
- Forum: Programs, Libraries and Tools
- Topic: usocket UDP and sockaddr questions
- Replies: 16
- Views: 17704
Re: usocket UDP and sockaddr questions
Sorry, I program Python for almost 20 years, but I don't see how that's "pretty clear". To a C programmer, maybe.pfalcon wrote:If you know Python, it should be pretty clear, that you use "bytes" for input (read only) parameter, and bytearray for output (read/write) parameter.
- Fri Nov 20, 2015 3:46 pm
- Forum: Programs, Libraries and Tools
- Topic: usocket UDP and sockaddr questions
- Replies: 16
- Views: 17704
Re: usocket UDP and sockaddr questions
Your C expertise doesn't let you read comments in English: https://github.com/micropython/micropython/blob/master/unix/modffi.c#L39 ? It actually is sufficient to infer most of the information in this comment* from https://github.com/micropython/micropython/blob/master/unix/modffi.c#L101, but not t...
- Fri Nov 20, 2015 3:06 pm
- Forum: Programs, Libraries and Tools
- Topic: usocket UDP and sockaddr questions
- Replies: 16
- Views: 17704
Re: usocket UDP and sockaddr questions
The first place to look at should be a source of a module. I tried, but it's a bit past my C expertise. And ffi module specifically is used a lot in micropython-lib, you can look there for various usage examples. Allright, it didn't occur to me to look there :( So, I always was under the impression...