Damien George
4abff7500f
py: Change uint to mp_uint_t in runtime.h, stackctrl.h, binary.h.
...
Part of code cleanup, working towards resolving issue #50 .
2014-08-30 14:59:21 +01:00
Damien George
4d91723587
py: Remove use of int type in obj.h.
...
Part of code cleanup, working towards resolving issue #50 .
2014-08-30 14:28:06 +01:00
Damien George
d182b98a37
py: Change all uint to mp_uint_t in obj.h.
...
Part of code cleanup, working towards resolving issue #50 .
2014-08-30 14:19:41 +01:00
Damien George
9c4cbe2ac0
py: Make tuple and list use mp_int_t/mp_uint_t.
...
Part of code cleanup, to resolve issue #50 .
2014-08-30 14:04:14 +01:00
Damien George
ecc88e949c
Change some parts of the core API to use mp_uint_t instead of uint/int.
...
Addressing issue #50 , still some way to go yet.
2014-08-30 00:35:11 +01:00
Damien George
17ae2395c2
py: Use memmove instead of memcpy when appropriate.
...
Found this bug by running unix/ tests with DEBUG=1 enabled when
compiling.
2014-08-29 21:07:54 +01:00
Damien George
a75b02ea9b
py: Improve efficiency of MP_OBJ_IS_STR_OR_BYTES.
...
Saves ROM (16 on stmhal, 240 on 64-bit unix) and should be quicker since
there is 1 less branch.
2014-08-27 09:20:30 +01:00
Dave Hylands
b7f7c655ed
Make int(b'123') work properly.
2014-08-26 19:15:04 -07: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
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
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
Damien George
bb4c6f35c6
py: Make MP_OBJ_NEW_SMALL_INT cast arg to mp_int_t itself.
...
Addresses issue #724 .
2014-07-31 10:49:14 +01:00
Damien George
5f27a7e811
py: Add mp_obj_str_builder_end_with_len.
...
This allows to create str's with a smaller length than initially asked
for.
2014-07-31 10:29:56 +01:00
Damien George
40f3c02682
Rename machine_(u)int_t to mp_(u)int_t.
...
See discussion in issue #50 .
2014-07-03 13:25:24 +01:00
Paul Sokolovsky
9e215fa4c2
py: Make unichar_charlen() accept/return machine_uint_t.
2014-06-28 23:15:29 +03:00
Damien George
e04a44e2f6
py: Small comments, name changes, use of machine_int_t.
2014-06-28 10:27:23 +01:00
Paul Sokolovsky
ea2c936c7e
objstrunicode: Refactor str_index_to_ptr() following objstr.
2014-06-27 00:04:20 +03:00
Paul Sokolovsky
26fda6dc8e
objstr: 64-bit issues.
2014-06-27 00:04:19 +03:00
Paul Sokolovsky
5048df0b7c
objstr: find(), rfind(), index(): Make return value be unicode-aware.
2014-06-27 00:04:19 +03:00
Paul Sokolovsky
cdc020da4b
objstrunicode: Re-add buffer protocol back for now, required for io.StringIO.
2014-06-27 00:04:18 +03:00
Paul Sokolovsky
d215ee1dc1
py: Make MICROPY_PY_BUILTINS_STR_UNICODE=1 buildable.
2014-06-27 00:04:18 +03:00
Paul Sokolovsky
9731912ccb
py: Prune unneeded code from objstrunicode, reuse code in objstr.
2014-06-27 00:04:18 +03:00
Paul Sokolovsky
e3cfc0d33d
objstr: Refactor to work with char pointers instead of indexes.
...
In preparation for unicode support.
2014-06-14 06:30:30 +03:00
Paul Sokolovsky
2ec38a17d4
objstr: Be 8-bit clean even for repr().
...
This will allow roughly the same behavior as Python3 for non-ASCII strings,
for example, print("<phrase in non-Latin script>".split()) will print list
of words, not weird hex dump (like Python2 behaves). (Of course, that it
will print list of words, if there're "words" in that phrase at all, separated
by ASCII-compatible whitespace; that surely won't apply to every human
language in existence).
2014-06-14 01:21:13 +03:00
Paul Sokolovsky
b4efac14cd
py: Make sure getattr() works with non-interned strings (by interning them).
2014-06-08 01:15:06 +03:00
Dave Hylands
b69f9fa31f
Fix str.modulo when precision is specified.
2014-06-05 23:09:02 -07:00
Damien George
d4c2bddd0c
py: Raise TypeError when trying to format non-int with %x,%o,%X.
...
This behaviour follows Python 3.5 standard (in 3.4 it's a
DeprecationWarning which we'd rather make a TypeError).
2014-06-05 19:44:54 +01:00
Damien George
11de8399fe
py: Small changes to objstr.c, including a bug fix.
...
Some small fixed:
- Combine 'x' and 'X' cases in str format code.
- Remove trailing spaces from some lines.
- Make exception messages consistently begin with lower case (then
needed to change those in objarray and objtuple so the same
constant string data could be used).
- Fix bug with exception message having %c instead of %%c.
2014-06-05 18:57:38 +01:00
Paul Sokolovsky
75ce9256b2
objstr: Implement "%(key)s" % {} formatting for strings and dicts.
...
Also, make sure that args to "*" format specifiers are bounds-checked
properly and don't lead for segfaults in case of mismatch.
2014-06-05 20:06:15 +03:00
Chris Angelico
9ab8ab2117
Replace assert(0) with a self-documenting TODO string
2014-06-05 06:05:57 +10:00
Chris Angelico
4867413e69
Simplify detection of quote characters in mp_str_print_quoted.
...
Once a double quote has been found, the subsequent discovery of a single quote
won't change behaviour at all, so don't bother looking for one.
2014-06-04 03:26:40 +10:00
Damien George
fcc9cf63f1
py, str: Replace enum with actual function pointer.
...
This way, it's slightly more efficient, uses less ROM (60 bytes less
for stmhal), and doesn't require to raise exception if bad operation
given.
2014-06-01 18:22:09 +01:00
Damien George
fb510b3bf9
Rename bultins config variables to MICROPY_PY_BUILTINS_*.
...
This renames:
MICROPY_PY_FROZENSET -> MICROPY_PY_BUILTINS_FROZENSET
MICROPY_PY_PROPERTY -> MICROPY_PY_BUILTINS_PROPERTY
MICROPY_PY_SLICE -> MICROPY_PY_BUILTINS_SLICE
MICROPY_ENABLE_FLOAT -> MICROPY_PY_BUILTINS_FLOAT
See issue #35 for discussion.
2014-06-01 13:32:54 +01:00
Paul Sokolovsky
ae9c82d5f3
objstr: str_uni_istype(): Spurious whitespace on empty lines.
2014-05-31 11:00:25 +03:00
Paul Sokolovsky
f69b9d379c
objstr: str_uni_istype(): Codestyle.
2014-05-31 10:59:34 +03:00
Kim Bauters
a3f4b83018
add methods isspace(), isalpha(), isdigit(), isupper() and islower() to str
2014-05-31 07:30:57 +01:00
Paul Sokolovsky
8827682b35
objstr: *strip(): If nothing is stripped, don't create dup string.
2014-05-30 03:15:17 +03:00
Paul Sokolovsky
bcdffe53c6
objstr: *strip(): Fix handling of one-char subject strings.
2014-05-30 03:15:17 +03:00
Damien George
f600a6a085
py: Slightly improve efficiency of mp_obj_new_str; rename str_new.
...
Reorder interning logic in mp_obj_new_str, to be more efficient.
str_new is globally accessible, so should be prefixed with mp_obj_.
2014-05-25 22:34:34 +01:00
Damien George
2617eebf2f
Change const byte* to const char* where sensible.
...
This removes need for some casts (at least, more than it adds need
for new casts!).
2014-05-25 22:27:57 +01:00
Paul Sokolovsky
5fd5af98d0
objlist: Implement support for arbitrary (3-arg) slices.
2014-05-25 22:12:56 +03:00
Paul Sokolovsky
de4b9329f9
py: Refactor slice helpers, preparing to support arbitrary slicing.
2014-05-25 21:21:57 +03:00
Paul Sokolovsky
69d081a7cf
py: Handle case of slice start > stop in common sequence function.
2014-05-25 02:29:40 +03:00
Paul Sokolovsky
afaaf535e6
objslice: Support arbitrary objects start, stop, and step.
...
Older int-only encoding is not expressive enough to support arbitrary slice
assignment operations.
2014-05-25 01:42:24 +03:00
Damien George
ee3fd46f13
Rename configuration variables controling Python features.
...
Now of the form MICROPY_PY_*. See issue #35 .
2014-05-24 23:03:12 +01:00
Paul Sokolovsky
d098c6bf85
objstr: Implement .endswith().
2014-05-24 22:46:51 +03:00
Damien George
6ac5dced24
py: Rename MP_OBJ_NOT_SUPPORTED to MP_OBJ_NULL.
...
See issue #608 for justification.
2014-05-21 19:42:43 +01:00
Paul Sokolovsky
c18ef2a9dd
objstr: startswith(): Accept optional "start" arg.
2014-05-15 21:33:18 +03:00
Paul Sokolovsky
70328e419a
py: Implement more complete bytes comparison handling.
2014-05-15 20:58:40 +03:00