Comments (8)
Yep, not yet implemented! This should be easy to do, just add the relevant functionality to py/objlist.c, in the function list_binary_op. Maybe someone wants to have a go at it? :)
from micropython.
I don't know if I will be able to find the time but I'll take a look. The related extend() method for lists is also missing but it's the same code.
While we're at it, string multiplication is also missing.
from micropython.
Thanks for that Chipaca. I had been tinkering on this this evening too but it seem that you got there first. Since you are already working on this shall I stop on the RT_BINARY_OP_INPLACE_ADD, RT_BINARY_OP_MULTIPLY and RT_BINARY_OP_INPLACE_MULTIPLY too?
I was also implementing list.extend(), which is similar to RT_BINARY_OP_INPLACE_ADD save that it needs to work with any iterable object. This lead me down three different ratholes which it would be helpful if Damien could clarify. These are (in no particular order):
- Can we count on the garbage collector to clear up heap objects allocated in the course of executing C code (such as iterator for other objects) without any hints being given? I'm used to coding for CPython so documenting the differences here would be helpful.
- What is the correct style for iterating over the items in an utterable object from within the C code? If the answer to the question above is 'yes' then I presume I just call the getiter function in the object structure and have at it.
- What is the correct style for throwing Python exceptions (such as type errors) from within C code? The binary_op table lets me just return NULL but if I am in a function like list.extend() and need to return a meaningful error I need to do some more.
While I can probably glean the answers to these from the rest of the code but it would help people getting started if we could have the answers to these written down somewhere.
from micropython.
As that was my first patch to the project I was waiting for feedback before moving on. So don't stop if you're doing the other ones.
Do, however, consider this: list.extend
is exactly the same as list.__iadd__
. That is, in CPython 3.3:
>>> a = []
>>> a += range(10)
>>> a
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
from micropython.
Aha. I had not noticed that:
l = [1,2,3]
l = l + 'foo'
behaves completely differently to:
l = [1,2,3]
l += 'foo'
Learn something new every day!
from micropython.
Now we have #42 & #43 . Bottom line: we should somehow sync who's going to/working on something. The process I propose is you post a ticket (if one doesn't exist), and also comment(s) on related ticket where you know it was discussed. Example: #46.
from micropython.
Yeap.
On Fri, Jan 3, 2014 at 11:06 AM, Paul Sokolovsky
[email protected]:
Now we have #42 #42 & #43#43. Bottom line: we should somehow sync who's going to/working on something.
The process I propose is you post a ticket (if one doesn't exist), and also
comment(s) on related ticket where you know it was discussed. Example: #46#46
.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/39#issuecomment-31516581
.
John Lenton ([email protected]) ::: http://chipaca.com
from micropython.
Both list addition and multiplication is implemented now, with unit tests.
from micropython.
Related Issues (20)
- invalid pin on esp32s3 HOT 1
- Arduino Nano Connect RP2040: Webrepl fails. HOT 3
- Base64 encoding into buffer, to reduce allocations HOT 3
- RMT read pulses?
- Update libffi to 3.3 or later to unblock CI for RV64. HOT 6
- ESP32-S3-FN8 SPIRAM errors on boot. HOT 8
- EXTI Power Voltage Detector doesn't work on STM32WB55 and STM32WL55 HOT 7
- RV32 native emitter fails compiling some of the tests HOT 22
- ESP32 wifi issues HOT 2
- Implement machine.USBDevice for ESP32-S3 HOT 2
- NUCLEO_F746ZG LAN stops working after few days.
- frambuf initalizes with ValueError HOT 8
- examples/network/https_client.py + cloudflare.com = OSError: 97 HOT 3
- ESP32-S3 FH4R2 v0.2 No WiFi HOT 3
- docs: Information missing about 'status' options while wifi is in AP mode + "Constants" module about security?
- Const with type hints is not optimized HOT 1
- Native code decorator should be best-effort
- docs: esp32s2 has no BLE support
- RP2350 / Pico 2 machine.lightsleep not working correctly HOT 1
- RP2350 / Pico 2 machine.deepsleep results in crash HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from micropython.