Skip to content
Snippets Groups Projects
  1. Sep 21, 2017
  2. Aug 20, 2017
  3. Jul 31, 2017
  4. Jun 15, 2017
  5. May 29, 2017
  6. Nov 13, 2016
  7. Oct 27, 2016
  8. Oct 17, 2016
  9. Oct 07, 2016
  10. Sep 22, 2016
  11. Aug 23, 2016
    • Krzysztof Blazewicz's avatar
      py/stream.c: use mp_obj_get_type in mp_get_stream_raise · 65620764
      Krzysztof Blazewicz authored
      In current state `mp_get_stream_raise` assumes that `self_in` is an object
      and always performs a pointer derefence which may cause a segfault.
      
      This function shall throw an exception whenever `self_in` does not implement
      a stream protocol, that includes qstr's and numbers.
      
      fixes #2331
      65620764
  12. Jul 30, 2016
  13. Jul 29, 2016
  14. Jul 26, 2016
  15. Jul 13, 2016
    • Paul Sokolovsky's avatar
      py/stream: Implement 2- and 3-arg write() method as an extension to CPython. · ad9b9c76
      Paul Sokolovsky authored
      3-arg form:
      
      stream.write(data, offset, length)
      
      2-arg form:
      
      stream.write(data, length)
      
      These allow efficient buffer writing without incurring extra memory
      allocation for slicing or creating memoryview() object, what is
      important for low-memory ports.
      
      All arguments must be positional. It might be not so bad idea to standardize
      on 3-arg form, but 2-arg case would need check and raising an exception
      anyway then, so instead it was just made to work.
      ad9b9c76
  16. Jun 18, 2016
  17. May 20, 2016
  18. May 17, 2016
    • Paul Sokolovsky's avatar
      py/stream: Support both "exact size" and "one underlying call" operations. · 7f7c84b1
      Paul Sokolovsky authored
      Both read and write operations support variants where either a) a single
      call is made to the undelying stream implementation and returned buffer
      length may be less than requested, or b) calls are repeated until requested
      amount of data is collected, shorter amount is returned only in case of
      EOF or error.
      
      These operations are available from the level of C support functions to be
      used by other C modules to implementations of Python methods to be used in
      user-facing objects.
      
      The rationale of these changes is to allow to write concise and robust
      code to work with *blocking* streams of types prone to short reads, like
      serial interfaces and sockets. Particular object types may select "exact"
      vs "once" types of methods depending on their needs. E.g., for sockets,
      revc() and send() methods continue to be "once", while read() and write()
      thus converted to "exactly" versions.
      
      These changes don't affect non-blocking handling, e.g. trying "exact"
      method on the non-blocking socket will return as much data as available
      without blocking. No data available is continued to be signaled as None
      return value to read() and write().
      
      From the point of view of CPython compatibility, this model is a cross
      between its io.RawIOBase and io.BufferedIOBase abstract classes. For
      blocking streams, it works as io.BufferedIOBase model (guaranteeing
      lack of short reads/writes), while for non-blocking - as io.RawIOBase,
      returning None in case of lack of data (instead of raising expensive
      exception, as required by io.BufferedIOBase). Such a cross-behavior
      should be optimal for MicroPython needs.
      7f7c84b1
  19. Apr 10, 2016
  20. Mar 27, 2016
  21. Mar 24, 2016
  22. Jan 11, 2016
  23. Dec 09, 2015
  24. Nov 29, 2015
  25. Oct 18, 2015
  26. Aug 13, 2015
  27. May 12, 2015
  28. Jan 28, 2015
    • Damien George's avatar
      py: Change vstr so that it doesn't null terminate buffer by default. · 0d3cb672
      Damien George authored
      This cleans up vstr so that it's a pure "variable buffer", and the user
      can decide whether they need to add a terminating null byte.  In most
      places where vstr is used, the vstr did not need to be null terminated
      and so this patch saves code size, a tiny bit of RAM, and makes vstr
      usage more efficient.  When null termination is needed it must be
      done explicitly using vstr_null_terminate.
      0d3cb672
  29. Jan 23, 2015
  30. Jan 21, 2015
    • Damien George's avatar
      py: Remove mp_obj_str_builder and use vstr instead. · 05005f67
      Damien George authored
      With this patch str/bytes construction is streamlined.  Always use a
      vstr to build a str/bytes object.  If the size is known beforehand then
      use vstr_init_len to allocate only required memory.  Otherwise use
      vstr_init and the vstr will grow as needed.  Then use
      mp_obj_new_str_from_vstr to create a str/bytes object using the vstr
      memory.
      
      Saves code ROM: 68 bytes on stmhal, 108 bytes on bare-arm, and 336 bytes
      on unix x64.
      05005f67
    • Damien George's avatar
      py: Add mp_obj_new_str_from_vstr, and use it where relevant. · 0b9ee861
      Damien George authored
      This patch allows to reuse vstr memory when creating str/bytes object.
      This improves memory usage.
      
      Also saves code ROM: 128 bytes on stmhal, 92 bytes on bare-arm, and 88
      bytes on unix x64.
      0b9ee861
  31. Jan 01, 2015
  32. Dec 05, 2014
Loading