@@ -1870,6 +1870,33 @@ Demo::
18701870
18711871
18721872
1873+ -- -
1874+
1875+
1876+
1877+ 3.14 `check_recursion` - Check if a function is recursive by inspecting its AST .
1878+
1879+
1880+ ```python
1881+ Returns True if the function calls itself, otherwise False .
1882+
1883+ Demo::
1884+ >> > def recursive_func():
1885+ ... return recursive_func()
1886+ >> > check_recursion(recursive_func)
1887+ True
1888+ >> > def non_recursive_func():
1889+ ... return 1 + 1
1890+ >> > check_recursion(non_recursive_func)
1891+ False
1892+ >> > # print is a std-lib function
1893+ >> > check_recursion(print , return_error = False )
1894+ >> > type (check_recursion(print , return_error = True ))
1895+ < class ' TypeError' >
1896+
1897+ ```
1898+
1899+
18731900-- -
18741901
18751902
@@ -2731,3 +2758,32 @@ Demo:
27312758-- -
27322759
27332760
2761+
2762+ 18.2 `SharedBytes` - Shared Memory for Python, for python 3.8 + .
2763+
2764+
2765+ ```python
2766+ This module provides a simple way to create and manage shared memory segments, shared between different processes.
2767+ Shared memory is faster than other IPC methods like pipes or queues, and it allows for direct access to the memory.
2768+
2769+ Demo:
2770+
2771+ >> > sb = SharedBytes(name = " test" , data = b " Hello, World!" , unlink_on_exit = True )
2772+ >> > # The size of the shared memory is 18 bytes (5 bytes for header + 13 bytes for data), but mac os may return more than 18 bytes.
2773+ >> > sb.size > 10
2774+ True
2775+ >> > sb.get(name = " test" )
2776+ b ' Hello, World!'
2777+ >> > sb.re_create(b " New Data" )
2778+ >> > sb.get(name = " test" )
2779+ b ' New Data'
2780+ >> > sb.close()
2781+ >> > sb.get(name = " test" , default = b " " ) # This will raise ValueError since the shared memory is closed
2782+ b ' '
2783+
2784+ ```
2785+
2786+
2787+ -- -
2788+
2789+
0 commit comments