Commit Graph

1593 Commits

Author SHA1 Message Date
Damien George a28507ab2b py: Detect unmatched tripple quote in repl helper. 2014-04-07 13:01:30 +01:00
Damien George 34ba06b076 Merge pull request #444 from lurch/test-sorted
Add tests for sorted() function
2014-04-07 12:52:28 +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
Andrew Scheller 5e443f4b70 Merge remote-tracking branch 'upstream/master' into makefile-tweaks 2014-04-07 01:41:24 +01:00
Andrew Scheller 902d9552c5 Replace some Makefile commands with variables in py/mkenv.mk 2014-04-07 01:35:45 +01:00
Damien George 2bfd2dc770 py: Revert revert for allocation policy of set hash table. 2014-04-07 01:16:17 +01:00
Paul Sokolovsky 46bd12d57e objset: Fix incorrect workaround against mp_set_init() munging alloc size.
No longer needed after recent change which guarantees that mp_set_init()
will allocate exact number of slots requested.
2014-04-07 03:08:46 +03:00
Paul Sokolovsky 4d2238d2ce tests: Fix more tests which depend on order of elements in set. 2014-04-07 03:08:46 +03:00
Damien George 3bb8663282 Merge branch 'master' of github.com:micropython/micropython 2014-04-07 00:54:53 +01: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 c75427baaa py: Revert change to allocation policy for mp_set_t.
Seems that this fixes all set tests.
2014-04-07 00:54:04 +01:00
Paul Sokolovsky 9f043da5c3 pip-micropython: Require command verb, but restrict to "install" only.
So, pip-micropython can/should be run as normal pip:

    pip-micropython install micropython-unittest
2014-04-07 02:53:41 +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
Damien George 36e75aef38 unix-cpy: Pass emit opt to mp_compile. 2014-04-06 19:48:43 +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
Paul Sokolovsky 7cf057aeeb objdict: Implement equality operator.
Sure, it's O(n^2).
2014-04-06 21:31:42 +03:00
Paul Sokolovsky 5fedd0c3b7 py: Fix dict.copy() and low-level map/set allocation.
Two things: 1) set flags in copy properly; make mp_map_init() not be too
smart and do something with requested alloc size. Policy of using prime
numbers for alloc size is high-level policy which should be applied at
corresponding high levels. Low-level functions should just do what they're
asked to, because they don't have enough context to be smarter than that.
For example, munging with alloc size of course breaks dict copying (as
changing sizes requires rehashing).
2014-04-06 21:31:42 +03:00
Paul Sokolovsky ea85a121f2 objdict: Support creating dict from another dict. 2014-04-06 20:08:56 +03:00
Damien George cdd96dff2c py: Implement more features in native emitter.
On x64, native emitter now passes 70 of the tests.
2014-04-06 12:58:40 +01:00
Damien George 65cad12d38 py: Add option to compiler to specify default code emitter.
Also add command line option to unix port to select emitter.
2014-04-06 11:48:15 +01:00
Damien George deed087e2c py: str.split: handle non-default separator. 2014-04-06 11:11:15 +01:00
Paul Sokolovsky 36dd19ae27 py: Revert mp_load_attr() to its previous state (not supporting default val).
Based on the discussion in #433. mp_load_attr() is critical-path function,
so any extra check will slowdown any script. As supporting default val
required only for getattr() builtin, move correspending implementation
there (still as a separate function due to concerns of maintainability
of such almost-duplicated code instances).
2014-04-06 02:15:23 +03:00
Damien George 4e1ed82583 Merge branch 'master' of github.com:micropython/micropython 2014-04-05 23:33:37 +01:00
Damien George d0e824387e py: Make mp_map_lookup not allocate memory on removal. 2014-04-05 23:33:12 +01:00
Paul Sokolovsky 080d99b7a8 py: Optimize locals()/globals() implementation. 2014-04-06 01:18:58 +03:00
Damien George 09af5364d4 Merge branch 'master' of github.com:micropython/micropython 2014-04-05 23:04:22 +01:00
Damien George 27e735fd18 py: Replace stream_p with *stream_p in mp_obj_type_t.
This is to reduce ROM usage.  stream_p is used in file and socket types
only (at the moment), so seems a good idea to make the protocol
functions a pointer instead of the actual structure.

It saves 308 bytes of ROM in the stmhal/ port, 928 in unix/.
2014-04-05 23:02:23 +01:00
Paul Sokolovsky cc0af3d727 py: Implement globals() and locals() builtins. 2014-04-06 01:01:36 +03:00
Damien George 17520224fa py: Make all objects and instances derive from object.
This makes isinstance(X, object) and issubclass(X, object) true for all
X.
2014-04-05 22:45:23 +01:00
Damien George 7efc5b3f34 py: Make globals and locals proper dictionary objects.
Finishes addressing issue #424.

In the end this was a very neat refactor that now makes things a lot
more consistent across the py code base.  It allowed some
simplifications in certain places, now that everything is a dict object.

Also converted builtins tables to dictionaries.  This will be useful
when we need to turn builtins into a proper module.
2014-04-05 22:36:42 +01:00
Damien George 8b0535e23f py: Change module globals from mp_map_t* to mp_obj_dict_t*.
Towards addressing issue #424.

Had a small increase to ROM usage (order 60 bytes).
2014-04-05 21:53:54 +01:00
Damien George 60be1cf3b9 py: Fix float printing on stmhal. 2014-04-05 20:51:29 +01:00
Damien George 12bab72d93 Improve GC finalisation code; add option to disable it. 2014-04-05 20:35:48 +01:00
Damien George 8123a3339d Merge pull request #425 from iabdalkader/del
Implement del
2014-04-05 18:49:39 +01:00
Damien George ea13f407a3 py: Change nlr_jump to nlr_raise, to aid in debugging.
This does not affect code size or performance when debugging turned off.

To address issue #420.
2014-04-05 18:32:08 +01:00
Damien George 2a037408af tests: Add test to check issue #429. 2014-04-05 18:17:51 +01:00
Damien George efccbf6f27 Merge pull request #436 from dhylands/pfenv-print-int
Change pfenv_print_int to take machine_uint_t rather than unsinged in
2014-04-05 18:11:02 +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
Dave Hylands 64ef5d7f4e Change pfenv_print_int to take machine_uint_t rather than unsinged in
With this change, the following works:

>>> print('%#x' % 0x1234567890abcdef)
0x1234567890abcdef
2014-04-05 09:42:20 -07:00
Damien George 6d508666ea Merge branch 'master' of github.com:micropython/micropython 2014-04-05 17:19:03 +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
Damien George e20b6b418c stmhal: autoflash now enters serial comms after flashing. 2014-04-05 17:16:00 +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
Paul Sokolovsky e99841be69 mp_obj_get_int(): Add warning against adding implicit float->int conversion. 2014-04-05 17:46:47 +03:00
mux cc849f70f4 Move del to locals 2014-04-05 15:49:03 +02:00
Damien George 09a4d8305d py: Fix bug in DELETE_SUBSCR bytecode, decreasing sp too much. 2014-04-05 13:47:41 +01:00