Skip to content
Snippets Groups Projects
  1. Jul 26, 2016
  2. 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
  3. Jun 18, 2016
  4. May 20, 2016
  5. 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
  6. Apr 10, 2016
  7. Mar 27, 2016
  8. Mar 24, 2016
  9. Jan 11, 2016
  10. Dec 09, 2015
  11. Nov 29, 2015
  12. Oct 18, 2015
  13. Aug 13, 2015
  14. May 12, 2015
  15. 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
  16. Jan 23, 2015
  17. 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
  18. Jan 01, 2015
  19. Dec 05, 2014
  20. Nov 16, 2014
  21. Oct 24, 2014
  22. Oct 23, 2014
  23. Oct 18, 2014
  24. Oct 17, 2014
  25. Oct 16, 2014
  26. Oct 15, 2014
  27. Aug 22, 2014
  28. Jul 27, 2014
  29. Jul 22, 2014
Loading