<feed xmlns='http://www.w3.org/2005/Atom'>
<title>suspect-devices/circuitpython/py/modbuiltins.c, branch v1.9.4</title>
<subtitle>CircuitPython - a Python implementation for teaching coding with microcontrollers</subtitle>
<id>https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=v1.9.4</id>
<link rel='self' href='https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=v1.9.4'/>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/'/>
<updated>2018-05-10T13:14:23+00:00</updated>
<entry>
<title>py/modbuiltins: Make built-in dir support the __dir__ special method.</title>
<updated>2018-05-10T13:14:23+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2018-05-10T13:10:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=3678a6bdc6a925f2bce6423c41f911229836f946'/>
<id>urn:sha1:3678a6bdc6a925f2bce6423c41f911229836f946</id>
<content type='text'>
If MICROPY_PY_ALL_SPECIAL_METHODS is enabled then dir() will now delegate
to the special method __dir__ if the object it is listing has this method.
</content>
</entry>
<entry>
<title>py/modbuiltins: In built-in dir make use of mp_load_method_protected.</title>
<updated>2018-05-10T13:07:19+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2018-05-10T13:07:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=29d28c2574d6c0b93fd3fc869b389a61dee12102'/>
<id>urn:sha1:29d28c2574d6c0b93fd3fc869b389a61dee12102</id>
<content type='text'>
This gives dir() better behaviour when listing the attributes of a user
type that defines __getattr__: it will now not list those attributes for
which __getattr__ raises AttributeError (meaning the attribute is not
supported by the object).
</content>
</entry>
<entry>
<title>py/modbuiltins: Make built-in hasattr work properly for user types.</title>
<updated>2018-05-10T13:03:30+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2018-05-10T13:03:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=529860643bc321267376272356886ef39c4c6bd1'/>
<id>urn:sha1:529860643bc321267376272356886ef39c4c6bd1</id>
<content type='text'>
It now allows __getattr__ in a user type to raise AttributeError when the
attribute does not exist.
</content>
</entry>
<entry>
<title>py/{modbuiltins,repl}: Start qstr probing from after empty qstr.</title>
<updated>2018-05-09T06:15:02+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2018-05-09T06:15:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=eb88803ac859db07726481501aea5c0e6bbf3705'/>
<id>urn:sha1:eb88803ac859db07726481501aea5c0e6bbf3705</id>
<content type='text'>
The list of qstrs starts with MP_QSTR_NULL followed by MP_QSTR_, and these
should never appear in dir() or REPL tab completion, so skip them.
</content>
</entry>
<entry>
<title>py/modbuiltins: Simplify and generalise dir() by probing qstrs.</title>
<updated>2018-02-19T05:12:44+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2018-02-15T07:12:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=98647e83c733a8a8d36522f71e677367ca8ddd03'/>
<id>urn:sha1:98647e83c733a8a8d36522f71e677367ca8ddd03</id>
<content type='text'>
This patch improves the builtin dir() function by probing the target object
with all possible qstrs via mp_load_method_maybe.  This is very simple (in
terms of implementation), doesn't require recursion, and allows to list all
methods of user-defined classes (without duplicates) even if they have
multiple inheritance with a common parent.  The downside is that it can be
slow because it has to iterate through all the qstrs in the system, but
the "dir()" function is anyway mostly used for testing frameworks and user
introspection of types, so speed is not considered a priority.

In addition to providing a more complete implementation of dir(), this
patch is simpler than the previous implementation and saves some code
space:

   bare-arm:   -80
minimal x86:   -80
   unix x64:   -56
unix nanbox:   -48
      stm32:   -80
     cc3200:   -80
    esp8266:  -104
      esp32:   -64
</content>
</entry>
<entry>
<title>py/modbuiltins: Simplify casts from char to byte ptr in builtin ord.</title>
<updated>2018-02-14T07:27:14+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2018-02-14T07:27:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=e98ff40604170eb231225a4285d9ef740b8b9501'/>
<id>urn:sha1:e98ff40604170eb231225a4285d9ef740b8b9501</id>
<content type='text'>
</content>
</entry>
<entry>
<title>py/unicode: Clean up utf8 funcs and provide non-utf8 inline versions.</title>
<updated>2018-02-14T07:19:22+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2018-02-14T07:19:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=19aee9438a7a8cf8539536dab5147aedb6b16bb3'/>
<id>urn:sha1:19aee9438a7a8cf8539536dab5147aedb6b16bb3</id>
<content type='text'>
This patch provides inline versions of the utf8 helper functions for the
case when unicode is disabled (MICROPY_PY_BUILTINS_STR_UNICODE set to 0).
This saves code size.

The unichar_charlen function is also renamed to utf8_charlen to match the
other utf8 helper functions, and the signature of this function is adjusted
for consistency (const char* -&gt; const byte*, mp_uint_t -&gt; size_t).
</content>
</entry>
<entry>
<title>py/modbuiltins: For builtin_chr, use uint8_t instead of char for array.</title>
<updated>2018-02-07T05:13:02+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2018-02-07T05:10:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=771dfb0826f7416848b4302ce8ce49a7a556a27f'/>
<id>urn:sha1:771dfb0826f7416848b4302ce8ce49a7a556a27f</id>
<content type='text'>
The array should be of type unsigned byte because that is the type of the
values being stored.  And changing to uint8_t helps to prevent warnings
from some static analysers.
</content>
</entry>
<entry>
<title>py/modbuiltins: Use standard arg-parsing helper func for builtin print.</title>
<updated>2017-12-05T01:14:57+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-12-05T01:14:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=58f00d7c0e116e17ab141ae18275edea14b88431'/>
<id>urn:sha1:58f00d7c0e116e17ab141ae18275edea14b88431</id>
<content type='text'>
This allows the function to raise an exception when unknown keyword args
are passed in.  This patch also reduces code size by (in bytes):

   bare-arm:   -24
minimal x86:   -76
   unix x64:   -56
unix nanbox:   -84
      stm32:   -40
    esp8266:   -68
     cc3200:   -48

Furthermore, this patch adds space (" ") to the set of ROM qstrs which
means it doesn't need to be put in RAM if it's ever used.
</content>
</entry>
<entry>
<title>py/modbuiltins: Slightly simplify code in builtin round().</title>
<updated>2017-11-22T04:51:51+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-11-22T04:51:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=d5cf5f70fdefa793d3e1fee9a26f03a1dd8c1d1e'/>
<id>urn:sha1:d5cf5f70fdefa793d3e1fee9a26f03a1dd8c1d1e</id>
<content type='text'>
</content>
</entry>
</feed>
