1. 15 Jun, 2017 1 commit
  2. 29 May, 2017 1 commit
  3. 13 Nov, 2016 1 commit
  4. 27 Oct, 2016 1 commit
  5. 17 Oct, 2016 1 commit
  6. 07 Oct, 2016 1 commit
  7. 22 Sep, 2016 1 commit
  8. 23 Aug, 2016 1 commit
    • 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
  9. 30 Jul, 2016 1 commit
  10. 29 Jul, 2016 1 commit
  11. 26 Jul, 2016 1 commit
  12. 13 Jul, 2016 1 commit
    • 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.
  13. 18 Jun, 2016 1 commit
  14. 20 May, 2016 1 commit
  15. 17 May, 2016 1 commit
    • 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.
  16. 10 Apr, 2016 5 commits
  17. 27 Mar, 2016 1 commit
  18. 24 Mar, 2016 2 commits
  19. 11 Jan, 2016 1 commit
  20. 09 Dec, 2015 1 commit
  21. 29 Nov, 2015 2 commits
  22. 18 Oct, 2015 1 commit
  23. 13 Aug, 2015 1 commit
  24. 12 May, 2015 1 commit
  25. 28 Jan, 2015 1 commit
    • 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.
  26. 23 Jan, 2015 2 commits
  27. 21 Jan, 2015 2 commits
    • 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
      Saves code ROM: 68 bytes on stmhal, 108 bytes on bare-arm, and 336 bytes
      on unix x64.
    • 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.
  28. 01 Jan, 2015 1 commit
  29. 05 Dec, 2014 1 commit
  30. 16 Nov, 2014 2 commits
  31. 24 Oct, 2014 1 commit