Damien George
ae8d867586
py: Add iter_buf to getiter type method.
Allows to iterate over the following without allocating on the heap:
- tuple
- list
- string, bytes
- bytearray, array
- dict (not dict.keys, dict.values, dict.items)
- set, frozenset
Allows to call the following without heap memory:
- all, any, min, max, sum
TODO: still need to allocate stack memory in bytecode for iter_buf.
9 years ago
Paul Sokolovsky
4463d8a910
extmod/modbtree: Rename "sync" method to "flush" for consistency.
Rename recently introduced "sync" method to "flush" for consistency with
usual files.
8 years ago
w4kpm
ec22d1739d
extmod/modbtree: Add method to sync the database.
If you have longish operations on the db (such as logging data) it may
be desirable to periodically sync the database to the disk. The added
btree.sync() method merely exposes the berkley __bt_sync function to the
user.
8 years ago
Damien George
75af908c0e
extmod: Use mp_raise_OSError helper function.
8 years ago
Damien George
93c4a6a3f7
all: Remove 'name' member from mp_obj_module_t struct.
One can instead lookup __name__ in the modules dict to get the value.
8 years ago
Krzysztof Blazewicz
5a5449d4eb
extmod/modbtree: do CHECK_ERROR after __bt_seq()
In `btree_seq()`, when `__bt_seq()` gets called with invalid
`flags` argument it will return `RET_ERROR` and it won't
initialize `val`. If field `data` of uninitialized `val`
is passed to `mp_obj_new_bytes()` it causes a segfault.
8 years ago
Paul Sokolovsky
d79342d33e
extmod/modbtree: open(): Add option kwargs.
Namely: flags, cachesize, pagesize, minkeypage.
8 years ago
Paul Sokolovsky
3eb532e974
extmod/modbtree: Implement __contains__ operation.
8 years ago
Paul Sokolovsky
99061d1dcb
extmod/modbtree: Switch to accepting stream object instead of filename.
Requires "embedded" BerkeleyDB BTree implementation.
8 years ago
Paul Sokolovsky
25df419c67
extmod/modbtree: Check __bt_open() return value for error.
8 years ago
Paul Sokolovsky
417dc0c05d
extmod/modbtree: Fixes for nanbox build.
8 years ago
Paul Sokolovsky
b09cd0e1ec
extmod/modbtree: Fix unused argument warning.
8 years ago
Paul Sokolovsky
2f7ebf16de
extmod/modbtree: Cleverly implement "for key in btree:" syntax.
I.e. make it work like btree.keys(), while still not using a separate
iterator type.
8 years ago
Paul Sokolovsky
6b088a671a
extmod/modbtree: Implement keys(), values(), items() iterators.
Each takes optional args of starting key, ending key, and flags (ending
key inclusive, reverse order).
9 years ago
Paul Sokolovsky
080137961d
extmod/modbtree: open(): Support "in-memory" database with filename=None.
It's not really in-memory though, just uses anonymous temporary file on
disk.
9 years ago
Paul Sokolovsky
e9739e3315
extmod/modbtree: __getitem__() should raise KeyError for non-existing key.
9 years ago
Paul Sokolovsky
e6e7e0e9c5
extmod/modbtree: items(): Implement DESC flag.
9 years ago
Paul Sokolovsky
332545baa3
extmod/modbtree: items(): Implement "end key inclusive" flag.
9 years ago
Paul Sokolovsky
d0416ff915
extmod/modbtree: Actually implement end key support for .items().
9 years ago
Paul Sokolovsky
1babeb47a4
extmod/modbtree: Implement .items() iterator.
9 years ago
Paul Sokolovsky
422396cece
extmod/modbtree: Handle default value and error check.
9 years ago
Paul Sokolovsky
8072162170
extmod/modbtree: Initial implementation of "btree" module based on BerkeleyDB.
This implements basic wrapping of native get/put/seq API, and then dictionary
access protocol. Native API is intended to be superceded going forward.
9 years ago