Damien George
686afc5c0a
py: Check that sequence has 2 elements for dict iterable constructor.
2014-04-11 09:13:30 +01:00
Paul Sokolovsky
be019ce063
objdict: Implement construction from iterable of pairs.
...
Pairs are limited to tuples so far.
2014-04-11 07:01:15 +03:00
Paul Sokolovsky
12a04392b9
objdict: Implement __getitem__ method.
2014-04-11 05:24:44 +03:00
Paul Sokolovsky
0c43cf9154
modstruct: Basic implementation of native struct alignment and types.
2014-04-11 03:59:16 +03:00
Paul Sokolovsky
6582d64d01
modstruct: Refactor to support both LE and BE packed structs.
2014-04-11 03:58:49 +03:00
Damien George
f31b6ff334
tests: Add test for multi-comparison.
2014-04-10 17:29:51 +00:00
Paul Sokolovsky
978607aeff
objfun: Fix default arguments filling loop, was broken in presense of kwargs.
2014-04-10 05:39:38 +03:00
Paul Sokolovsky
e9db840480
py: Start implementing "struct" module.
...
Only calcsize() and unpack() functions provided so far, for little-endian
byte order. Format strings don't support repition spec (like "2b3i").
Unfortunately, dealing with all the various binary type sizes and alignments
will lead to quite a bloated "binary" helper functions - if optimizing for
speed. Need to think if using dynamic parametrized algos makes more sense.
2014-04-10 03:58:03 +03:00
Damien George
038fd52faa
Merge branch 'str-index' of github.com:xbe/micropython into xbe-str-index
2014-04-09 20:44:37 +01:00
Damien George
a157e4caba
py: str.join can now take arbitrary iterable as argument.
2014-04-09 19:17:53 +01:00
Damien George
13d6739cc7
py: Generators can have their locals closed over.
2014-04-09 19:01:45 +01:00
Damien George
2bf7c09222
py: Properly implement deletion of locals and derefs, and detect errors.
...
Needed to reinstate 2 delete opcodes, to specifically check that a local
is not deleted twice.
2014-04-09 15:26:46 +01:00
Paul Sokolovsky
a985b4593d
objint: Implement int.from_bytes() class method and .to_bytes() method.
...
These two are apprerently the most concise and efficient way to convert
int to/from bytes in Python. The alternatives are struct and array modules,
but methods using them are more verbose in Python code and less efficient
in memory/cycles.
2014-04-09 01:07:37 +03:00
Damien George
2b0091983f
tests: Oops: fix del-attr.
2014-04-08 23:02:24 +01:00
Damien George
f4c9b33abf
py: Remove DELETE_SUBSCR opcode, combine with STORE_SUBSCR.
...
This makes the runtime and object APIs more consistent. mp_store_subscr
functionality now moved into objects (ie list and dict store_item).
2014-04-08 21:32:29 +01:00
Paul Sokolovsky
4dcb605ac4
py: Make bytearray a proper type.
2014-04-08 22:11:40 +03:00
xbe
3d9a39e211
py: Implement str.[r]index() and add tests for them.
2014-04-08 11:51:41 -07:00
Damien George
134c10e776
Merge branch 'master' of github.com:micropython/micropython
2014-04-08 18:29:50 +01:00
Damien George
495d781a36
py: implement UNPACK_EX byte code (for: a, *b, c = d)
2014-04-08 17:51:47 +01:00
Paul Sokolovsky
b9cf3d3730
bytearray: Support bytearray(int) constructor.
...
To create bytearray of given length.
2014-04-08 19:08:34 +03:00
Andrew Scheller
12968fb6b2
Display \r and \t escape codes in string repr
2014-04-08 02:42:50 +01:00
Dave Hylands
c4029e5079
Add string formatting support for longlong and mpz.
2014-04-07 11:38:45 -07:00
Damien George
1422865c99
Merge pull request #445 from lurch/test-sorted-sets
...
Modify set tests to print sorted sets directly
2014-04-07 13:15:33 +01:00
Andrew Scheller
1ff6011abc
Modify set tests to print sorted sets directly
...
instead of creating temporary lists and sorting those in-place
2014-04-07 05:00:03 +01:00
Andrew Scheller
a1a9ab2b2c
Add tests for sorted() function
...
and check that sorted(list) produces same output as list.sort()
2014-04-07 04:41:54 +01:00
Paul Sokolovsky
4d2238d2ce
tests: Fix more tests which depend on order of elements in set.
2014-04-07 03:08:46 +03:00
Paul Sokolovsky
bd6f3d31d2
tests: Fix few tests which depend on order of elements in set.
2014-04-07 02:54:16 +03:00
Damien George
07e24a6294
tests: Fix tests with sets to print sorted set.
2014-04-07 00:42:09 +01:00
Damien George
ff715429ea
py: Fix str.replace for case when arg 0 or 1 is empty string.
2014-04-07 00:39:13 +01:00
Paul Sokolovsky
b4dea46d8b
tests: Fix few tests which depend on order of elements in dict.
...
With dict being unordered of course.
2014-04-06 21:31:42 +03:00
Paul Sokolovsky
e2adff3608
tests/dict2.py: Add combined test for dict(dict) and dict equality.
2014-04-06 21:31:42 +03:00
Damien George
deed087e2c
py: str.split: handle non-default separator.
2014-04-06 11:11:15 +01:00
Damien George
2a037408af
tests: Add test to check issue #429 .
2014-04-05 18:17:51 +01:00
Damien George
327a3e2faa
Merge pull request #435 from dhylands/str-modulo-float
...
Allow floating point arguments with %d,i,u,o,x,X formats
2014-04-05 18:10:11 +01:00
Damien George
23419a2f8a
Merge pull request #433 from pfalcon/getattr-3arg
...
py: Support 3-arg getattr() builtin (with default value).
2014-04-05 18:00:04 +01:00
Damien George
95004e5114
py: Fix delete operation on map/dict and set objects.
...
Hash table can now be completely full (ie now NULL entry) before a
resize is triggered. Use sentinel value to indicate delete entry in the
table.
2014-04-05 17:17:19 +01:00
Dave Hylands
f81a49e464
Allow floating point arguments with %d,i,u,o,x,X formats
2014-04-05 08:26:51 -07:00
Damien George
b6ec51bbf0
tests: Add test for dict delete. It fails.
2014-04-05 13:26:00 +01:00
Paul Sokolovsky
bfb7d6a26d
py: Support 3-arg getattr() builtin (with default value).
2014-04-05 13:34:02 +03:00
Paul Sokolovsky
438d504e27
objtype: Add equality test for type types.
2014-04-05 13:10:56 +03:00
Paul Sokolovsky
91cbe6033a
py: Allow types to be hashable.
...
Quite natural to have d[int] = handle_int .
2014-04-05 12:51:58 +03:00
Damien George
9b1599c663
Merge pull request #422 from dhylands/str-modulo
...
Str modulo
2014-04-04 12:37:52 +01:00
Damien George
6902eeda25
py: Add m_malloc_fail function to handle memory allocation error.
...
A malloc/realloc fail now throws MemoryError.
2014-04-04 10:52:59 +00:00
Dave Hylands
6756a37a77
Implements most of str.modulo
...
The alternate form for floating point doesn't work yet.
The %(name)s form doesn't work yet.
2014-04-03 23:55:02 -07:00
Damien George
c322c5f07f
py: Fix regress for printing of floats and #if.
...
Also change formating modifier in test script (it still passes with
original format though).
2014-04-02 20:04:15 +01:00
Paul Sokolovsky
ad1bac63f7
tests/string-format: Add test for formatting ints with float format.
...
Fail currently.
2014-04-02 20:41:34 +03:00
Damien George
10e21b9770
Add more tests.
2014-04-02 14:23:04 +01:00
Damien George
93b7faa29a
py: Factor out static/class method unwrapping code; add tests.
2014-04-02 14:13:26 +01:00
Damien George
4881566874
py: Add support for sep and end keywords in print.
2014-04-02 10:34:44 +01:00
Damien George
084ef373fb
py: Fix math.{ceil,floor,trunc} to return int.
2014-04-01 21:21:50 +01:00