RestrictedPython defines a safe subset of the Python language by transforming the Abstract Syntax Tree (AST), disallowing dangerous imports and operations to execute untrusted code within a single process. It is used in applications like Zope and Redash for safe template evaluation and query execution.