Exercises
The possibilities with external libraries are endless, so perhaps you already have some ideas about what to implement. If not, here’s some inspiration:
- Try to sort a list of numbers using
ctypes
,CFFI
, and with a native extension. You can use theqsort
function instdlib
. - Try to make the
custom_sum
function we created safer by adding proper errors for overflow/underflow issues. Additionally, catch the errors when summing multiple numbers that only overflow or underflow in summation.
These exercises should be a nice starting point for doing something useful with your newly acquired knowledge. If you are looking for more of the native C/C++ examples, I would recommend looking through the CPython source. There are many examples available: https://github.com/python/cpython/tree/main/Modules. I would suggest starting with a relatively simple one such as the bisect
module.
Example answers for these exercises can be found on GitHub: https...