Performance optimizations and type hints