micropython/py
Dave Hylands 9f76dcd682 py: Prevent many extra vstr allocations.
I checked the entire codebase, and every place that vstr_init_len
was called, there was a call to mp_obj_new_str_from_vstr after it.

mp_obj_new_str_from_vstr always tries to reallocate a new buffer
1 byte larger than the original to store the terminating null
character.

In many cases, if we allocated the initial buffer to be 1 byte
longer, we can prevent this extra allocation, and just reuse
the originally allocated buffer.

Asking to read 256 bytes and only getting 100 will still cause
the extra allocation, but if you ask to read 256 and get 256
then the extra allocation will be optimized away.

Yes - the reallocation is optimized in the heap to try and reuse
the buffer if it can, but it takes quite a few cycles to figure
this out.

Note by Damien: vstr_init_len should now be considered as a
string-init convenience function and used only when creating
null-terminated objects.
2015-07-06 17:29:27 +01:00
..
argcheck.c
asmarm.c py: Implement native multiply operation in viper emitter. 2015-06-04 14:00:29 +00:00
asmarm.h py: Implement native multiply operation in viper emitter. 2015-06-04 14:00:29 +00:00
asmthumb.c
asmthumb.h
asmx64.c py: Implement native multiply operation in viper emitter. 2015-06-04 14:00:29 +00:00
asmx64.h py: Implement native multiply operation in viper emitter. 2015-06-04 14:00:29 +00:00
asmx86.c py: Implement native multiply operation in viper emitter. 2015-06-04 14:00:29 +00:00
asmx86.h py: Implement native multiply operation in viper emitter. 2015-06-04 14:00:29 +00:00
bc.c
bc.h
bc0.h py: Remove mp_load_const_bytes and instead load precreated bytes object. 2015-06-25 14:42:13 +00:00
binary.c py/binary: Make return type of mp_binary_get_size size_t instead of int. 2015-05-17 18:12:19 +01:00
binary.h py/binary: Make return type of mp_binary_get_size size_t instead of int. 2015-05-17 18:12:19 +01:00
builtin.h modstruct: Rename module to "ustruct", to allow full Python-level impl. 2015-05-04 16:53:52 +03:00
builtinevex.c
builtinimport.c builtinimport: Fix running package submodule with -m. 2015-06-29 00:26:45 +03:00
compile.c py: Remove mp_load_const_bytes and instead load precreated bytes object. 2015-06-25 14:42:13 +00:00
compile.h
emit.h py: Remove mp_load_const_bytes and instead load precreated bytes object. 2015-06-25 14:42:13 +00:00
emitbc.c py: Remove mp_load_const_bytes and instead load precreated bytes object. 2015-06-25 14:42:13 +00:00
emitcommon.c
emitcpy.c py: Remove mp_load_const_bytes and instead load precreated bytes object. 2015-06-25 14:42:13 +00:00
emitglue.c
emitglue.h
emitinlinethumb.c
emitnative.c py: Remove mp_load_const_bytes and instead load precreated bytes object. 2015-06-25 14:42:13 +00:00
formatfloat.c py: Implement mp_format_float for doubles and use where appropriate 2015-05-17 21:47:11 +01:00
formatfloat.h py: Implement mp_format_float for doubles and use where appropriate 2015-05-17 21:47:11 +01:00
frozenmod.c frozenmod: Include header with function prototypes. 2015-05-31 23:02:04 +03:00
frozenmod.h
gc.c
gc.h
grammar.h py: Clean up some bits and pieces in parser, grammar. 2015-04-21 16:43:18 +00:00
lexer.c py: Cast argument for printf to int, to be compatible with more ports. 2015-06-22 17:40:12 +01:00
lexer.h unix: Allow to cat a script into stdin from the command line. 2015-06-04 23:42:45 +01:00
lexerstr.c
lexerunix.c unix: Allow to cat a script into stdin from the command line. 2015-06-04 23:42:45 +01:00
makeqstrdata.py py: Get makeqstrdata.py and makeversionhdr.py running under Python 2.6. 2015-05-30 23:11:16 +01:00
makeversionhdr.py py: Get makeqstrdata.py and makeversionhdr.py running under Python 2.6. 2015-05-30 23:11:16 +01:00
malloc.c
map.c py: Convert hash API to use MP_UNARY_OP_HASH instead of ad-hoc function. 2015-05-12 22:46:02 +01:00
misc.h extmod: Add ubinascii.unhexlify 2015-05-20 09:29:22 +01:00
mkenv.mk
mkrules.mk mkrules.mk: Add comment why dependency parsing regex was tweaked. 2015-05-06 15:34:33 +03:00
modarray.c
modbuiltins.c py: Add MP_BINARY_OP_DIVMOD to simplify and consolidate divmod builtin. 2015-06-13 23:36:30 +01:00
modcmath.c
modcollections.c
modgc.c
modio.c
modmath.c py: Implement second arg for math.log (optional value for base). 2015-06-13 22:35:25 +01:00
modmicropython.c
modstruct.c modstruct: Raise NotImplementedError for unsupported repeat specification. 2015-07-05 22:44:14 +03:00
modsys.c py: Replace py-version.sh with makeversionhdr.py, written in Python. 2015-04-28 23:52:36 +01:00
mpconfig.h py: Add TimeoutError exception subclassed from OSError. 2015-07-02 11:53:08 +02:00
mpprint.c py: Remove unnecessary extra handling of padding of nan/inf. 2015-05-28 14:22:12 +00:00
mpprint.h py: Remove unnecessary extra handling of padding of nan/inf. 2015-05-28 14:22:12 +00:00
mpstate.c
mpstate.h modsys: Add basic sys.exc_info() implementation. 2015-04-25 03:49:23 +03:00
mpz.c py: Fix handling of negative numbers in struct.pack of q/Q. 2015-04-25 23:51:14 +01:00
mpz.h py: Support conversion of bignum to bytes. 2015-04-25 23:16:39 +01:00
nativeglue.c py: Remove mp_load_const_bytes and instead load precreated bytes object. 2015-06-25 14:42:13 +00:00
nlr.h
nlrsetjmp.c
nlrthumb.S
nlrx64.S
nlrx86.S
nlrxtensa.S
obj.c py: Add mp_obj_get_int_truncated and use it where appropriate. 2015-05-12 23:05:53 +01:00
obj.h py: Add TimeoutError exception subclassed from OSError. 2015-07-02 11:53:08 +02:00
objarray.c py/objarray.c: Allow to build with debugging and bytearray but no array. 2015-07-02 16:26:57 +01:00
objattrtuple.c py: Fix attrtuple array length in print and creation. 2015-04-29 00:17:48 +01:00
objbool.c py: Convert hash API to use MP_UNARY_OP_HASH instead of ad-hoc function. 2015-05-12 22:46:02 +01:00
objboundmeth.c
objcell.c
objclosure.c
objcomplex.c py: Implement mp_format_float for doubles and use where appropriate 2015-05-17 21:47:11 +01:00
objdict.c
objenumerate.c
objexcept.c py: Add TimeoutError exception subclassed from OSError. 2015-07-02 11:53:08 +02:00
objexcept.h
objfilter.c
objfloat.c py: Add MP_BINARY_OP_DIVMOD to simplify and consolidate divmod builtin. 2015-06-13 23:36:30 +01:00
objfun.c py: Fallback to stack alloca for Python-stack if heap alloc fails. 2015-06-08 22:07:27 +01:00
objfun.h
objgenerator.c objgenerator: Can optimize StopIteration to STOP_ITERATION only if arg is None. 2015-05-11 23:57:42 +01:00
objgenerator.h
objgetitemiter.c
objint.c py: Convert hash API to use MP_UNARY_OP_HASH instead of ad-hoc function. 2015-05-12 22:46:02 +01:00
objint.h py: Support conversion of bignum to bytes. 2015-04-25 23:16:39 +01:00
objint_longlong.c py: Convert hash API to use MP_UNARY_OP_HASH instead of ad-hoc function. 2015-05-12 22:46:02 +01:00
objint_mpz.c py: Implement divmod for mpz bignum. 2015-06-13 23:38:28 +01:00
objlist.c
objlist.h
objmap.c
objmodule.c modstruct: Rename module to "ustruct", to allow full Python-level impl. 2015-05-04 16:53:52 +03:00
objmodule.h
objnamedtuple.c
objnone.c py: Convert hash API to use MP_UNARY_OP_HASH instead of ad-hoc function. 2015-05-12 22:46:02 +01:00
objobject.c py/objobject: Don't make locals_dict if there's nothing to go in it. 2015-05-17 17:48:47 +01:00
objproperty.c
objrange.c
objreversed.c
objset.c
objsingleton.c objsingleton: New home for Ellipsis and NotImplemented. 2015-05-05 22:18:07 +03:00
objslice.c objsingleton: New home for Ellipsis and NotImplemented. 2015-05-05 22:18:07 +03:00
objstr.c py: Prevent many extra vstr allocations. 2015-07-06 17:29:27 +01:00
objstr.h
objstringio.c
objstrunicode.c py: Clean up declarations of str type/funcs that are also in unicode. 2015-05-17 16:44:24 +01:00
objtuple.c py: Convert hash API to use MP_UNARY_OP_HASH instead of ad-hoc function. 2015-05-12 22:46:02 +01:00
objtuple.h
objtype.c py: Add MP_BINARY_OP_DIVMOD to simplify and consolidate divmod builtin. 2015-06-13 23:36:30 +01:00
objtype.h py: Check that arg to object.__new__ is a user-defined type. 2015-05-04 11:08:40 +01:00
objzip.c
opmethods.c
parse.c py: Clean up some bits and pieces in parser, grammar. 2015-04-21 16:43:18 +00:00
parse.h
parsenum.c py: Clarify comment in parsenum.c about ValueError vs SyntaxError. 2015-06-23 16:08:51 +00:00
parsenum.h
parsenumbase.c
parsenumbase.h
py.mk py: Rebuild port if mpconfigport.mk changed (if any). 2015-06-11 11:08:39 +03:00
qstr.c
qstr.h
qstrdefs.h extmod: Add a2b_base64 and b2a_base64 functions to ubinascii. 2015-07-04 12:26:52 +03:00
repl.c py/repl: Fix case where shorter names are shadowed by longer names. 2015-07-06 14:00:09 +01:00
repl.h py, readline: Add tab autocompletion for REPL. 2015-04-29 00:46:26 +01:00
runtime.c runtime: Improve mp_import_name() debug logging. 2015-06-27 00:40:21 +03:00
runtime.h py: Remove mp_load_const_bytes and instead load precreated bytes object. 2015-06-25 14:42:13 +00:00
runtime0.h py: Remove mp_load_const_bytes and instead load precreated bytes object. 2015-06-25 14:42:13 +00:00
scope.c
scope.h
sequence.c
showbc.c py: Remove mp_load_const_bytes and instead load precreated bytes object. 2015-06-25 14:42:13 +00:00
smallint.c
smallint.h
stackctrl.c
stackctrl.h
stream.c py: Add mp_obj_get_int_truncated and use it where appropriate. 2015-05-12 23:05:53 +01:00
stream.h
unicode.c py: Minor improvement to unichar_isxdigit 2015-05-20 09:31:22 +01:00
unicode.h
vm.c py: Remove mp_load_const_bytes and instead load precreated bytes object. 2015-06-25 14:42:13 +00:00
vmentrytable.h py: Remove mp_load_const_bytes and instead load precreated bytes object. 2015-06-25 14:42:13 +00:00
vstr.c py: Prevent many extra vstr allocations. 2015-07-06 17:29:27 +01:00
warning.c