å§ãã«
pydantic
çã®Pythonã®ã©ã¤ãã©ãªã¯ã³ã¢é¨åãRustã§æ¸ããã¦ãã¦ãPythonã§ãååãªå¦çé度ã確ä¿ããã¦ãããã¨ãã表ç¾ãããããã¨ãããã¾ãã
ãã®ãããåºæ¬çã«ã¯Rustã§ä½ãããã©ã¤ãã©ãªã«ç§»è¡ãããã¨ãã¦ããã³ãã¬ã¼ãã¨ã³ã¸ã³ã®jinja2
ããminijinja
ã«ç§»è¡ãããã¨ãã¾ããããã®éç¨ã§æ°ä»ãããã¨ãã¡ã¢ããã ãã®è¨äºã§ãã
â» Pythonã®minijinjaã«ã¤ãã¦ã¯ã試é¨çãªè©¦ã¿ã§minijinjaåä½ã®æ©è½ãå®å ¨ã«ç§»è¡ããã¦ããããã§ã¯ãªãããå¦çé度ãæ©ãã¨ãã¯æè¨ããã¦ããªãã®ã§ãç¾æç¹ã§ç§»è¡ã¯å§ããªãã§ãã
minijinja-py is an experimental binding of MiniJinja to Python
ç°å¢
- Python
- 3.13
- jinja2
- 3.15
- minijinja
- 1.63
ã¾ã¨ã
- Rust製ã©ã¤ãã©ãªã¯å¦çé度é¢ã§åªä½ãªãã¨ãå¤ã
- Ruståä½ã§ãã«ãããã¨ãã¯ãã¤ããªãã¡ã¤ã«ã«ãããã®ã§è»½ã
- Pythonã¨ã®äºææ§ãæããããµã¤ãºã大ããã®ã§ãç·åçã«ã¯ãµã¤ãºã大ãããªããã¡
æ°ä»ãããã¨
jinja2
ããminijinja
ã®ãµã¤ãºã確èªããã¨ãã«æ°ä»ãã¾ããã
uv pip list --format freeze | awk -F = {'print $1'} | grep -E 'jinja2|minijinja' | xargs uv pip show | grep -E 'Location:|Name:' | cut -d ' ' -f 2 | paste -d ' ' - - | awk '{print $2 "/" tolower($1)}' | xargs du -sh 2> /dev/null | sort -hr 2.1M /products/fastapi-practice/.venv/lib/python3.13/site-packages/minijinja 536K /products/fastapi-practice/.venv/lib/python3.13/site-packages/jinja2
ã³ãã³ãã®å®è¡çµæãè¦ã¦åããã¨ãããjinja2
ã¯536kç¨åº¦ã«ãããããããminijinja
ã¯2.1Mããµã¤ãºãããã¾ããå
·ä½çã«ã©ãã®ãã¡ã¤ã«ã大ãããã¨ããã¨ãRust製ã©ã¤ãã©ãªã®ã³ã¢é¨åã§ãã
# ls -ltrah -rw-r--r-- 2 hiroto hiroto 238 Nov 17 23:38 _lowlevel.pyi -rw-r--r-- 2 hiroto hiroto 558 Nov 17 23:38 _internal.py -rw-r--r-- 2 hiroto hiroto 5.1K Nov 17 23:38 __init__.pyi -rw-r--r-- 2 hiroto hiroto 5.3K Nov 17 23:38 __init__.py -rwxr-xr-x 2 hiroto hiroto 2.1M Nov 17 23:38 _lowlevel.abi3.so
ã¡ãªã¿ã«ãRustã®crates.ioãè¦ãã¨åããã®ã§ããRustä¸ã§ä½¿ç¨ããå ´åã¯156KBç¨åº¦ã§ãã
ã¾ããä¼ç¤¾ã§ä½¿ç¨ãã¦ããFastAPIããã¸ã§ã¯ããPython3.13ã«ã¢ãããã¼ããããã¨ããããDocker Imageã®ãµã¤ãºã1GBãããã¾ã§è¨ããã§ãã¾ãã¾ãããPython3.12ã§ã800MBãããã«ãªã£ã¦ãã¾ãã
çµããã«
Rustã®é«éãªå¦çè½åã¨Pythonã®è±å¯ãªã©ã¤ãã©ãªã¨ã³ã·ã¹ãã ã使ç¨ã§ãããã¨ã¯åã°ããã®ã§ãããDockerã®ã¤ã¡ã¼ã¸ãµã¤ãºãã©ãã©ã大ãããªã£ã¦ããã®ãå°ãã¾ãããæ£ç´ãæè¦çã«ãµã¤ãºå¤§ããã¨æãã¦ããã ãã§ã¯ããã®ã§ã1GBã¨ããå½ããåã§ãããªãããã¯ããã§ããã®ã§ããâ¦ã
ããPythonã®ããã¸ã§ã¯ããDockerã®ã¤ã¡ã¼ã¸åããéã«ãã¤ã¡ã¼ã¸ãµã¤ãºããã¤ã¨ãããããæ¹æ³ãããã°æãã¦ããã ãããã§ããå®éç¨ä¸ã¯ECRã使ç¨ãã¦ããã®ã§ãå®ã¯ãªãã·ã§ã³ã§å§ç¸®å¯è½ã ã£ããããããã£ã¨å¬ããã§ãã
åèæ å ±
- PyPIã®minijinja
- crates.ioã®minijinja