Damien George
26a0d4f4f1
py: Change hash and len members of str from 16 bit to full word.
...
This allows to make strings longer than 64k. It doesn't use any more
RAM with current GC because a str object still fits in a GC block.
2014-08-22 18:34:28 +01:00
Damien George
69b7dae362
py: Small cleanup in stream.c.
2014-08-22 18:30:02 +01:00
Damien George
d5e7f6e37e
py: Speed up GC allocation.
...
This simple patch gives a very significant speed up for memory allocation
with the GC.
Eg, on PYBv1.0:
tests/basics/dict_del.py: 3.55 seconds -> 1.19 seconds
tests/misc/rge_sm.py: 15.3 seconds -> 2.48 seconds
2014-08-22 18:17:02 +01:00
Damien George
7fe2191c9b
py: Code clean-up in native emitter; improve thumb native calls.
2014-08-16 22:31:57 +01:00
Damien George
86de21b810
py: Viper can call functions with native types, and raise exceptions.
2014-08-16 22:06:11 +01:00
Damien George
8f81b5cb4b
py: Put SystemExit in builtin namespace.
...
Also fix unix port so that SystemExit with no arg exits with value 0.
2014-08-16 14:32:06 +01:00
Damien George
e6c0dff967
py: Viper can now store to global.
2014-08-15 23:47:59 +01:00
Damien George
a5190a7dac
py: Fix typing of viper locals; allow default types in annotation.
2014-08-15 22:39:08 +01:00
Damien George
2ac4af6946
py: Allow viper to have type annotations.
...
Viper functions can now be annotated with the type of their arguments
and return value. Eg:
@micropython.viper
def f(x:int) -> int:
return x + 1
2014-08-15 16:45:41 +01:00
Damien George
6be0b0a8ec
py: Clean up and simplify functions in scope; add STATIC in compiler.
...
Some small code clean-ups that result in about 80 bytes ROM saving for
stmhal.
2014-08-15 14:30:52 +01:00
Damien George
9b7a8ee8f1
py: Fix mult by negative number of tuple, list, str, bytes.
...
Multiplication of a tuple, list, str or bytes now yields an empty
sequence (instead of crashing). Addresses issue #799
Also added ability to mult bytes on LHS by integer.
2014-08-13 13:22:24 +01:00
Paul Sokolovsky
510296f25a
modzlibd: Decompress part of "zlib" module, based on miniz tinfl.c .
2014-08-13 00:26:19 +03:00
Damien George
75ec22bf11
py: #if guard qstrs that are optional.
...
Also disable gc module on bare-arm port.
2014-08-12 20:16:03 +01:00
Damien George
f20375eedd
py: Add .real and .imag attributes to complex numbers.
2014-08-12 19:57:52 +01:00
Damien George
bb91f1195a
py: Improve range: add len, subscr, proper print.
...
Can now index ranges with integers and slices, and reverse ranges
(although reversing is not very efficient).
Not sure how useful this stuff is, but gets us closer to having all of
Python's builtins.
2014-08-12 19:41:18 +01:00
Damien George
4c03b3a899
py: Implement builtin reversed() function.
...
reversed function now implemented, and works for tuple, list, str, bytes
and user objects with __len__ and __getitem__.
Renamed mp_builtin_len to mp_obj_len to make it publically available (eg
for reversed).
2014-08-12 18:33:40 +01:00
Damien George
69c5fe1df6
py: Make a function static; replace NULL with MP_OBJ_NULL.
2014-08-12 18:13:44 +01:00
Damien George
2eb1f604ee
py, objstr: Optimise bytes subscr when unicode is enabled.
...
Saves code bytes and makes it faster, so why not?
2014-08-11 23:24:29 +01:00
Damien George
7703d71938
py, modcmath: Fix doc comment, and add some more of them.
2014-08-11 22:19:44 +00:00
Paul Sokolovsky
9749b2fb0d
objstr: Make sure that bytes are indexed as bytes, not as unicode.
...
Fixes #795 .
2014-08-11 22:38:00 +03:00
Paul Sokolovsky
0c5498540b
objstr: split(): check arg type consistency (str vs bytes).
...
Similar to other methods and following CPython3 strictness.
2014-08-10 23:21:16 +03:00
Paul Sokolovsky
ecca53bd34
py: binary.c: Properly implement alignment for native unpacked structs.
2014-08-10 23:21:08 +03:00
Damien George
4ef26c14b1
doc: Fix up a few docs in sys module.
2014-08-10 17:53:43 +01:00
Damien George
30dd23aa7f
doc: Document gc, sys, math, cmath.
2014-08-10 17:50:28 +01:00
Paul Sokolovsky
5f930337bc
objarray: Implement equality testing between arrays and other buffers.
2014-08-10 16:22:57 +03:00