---
title: "Discussion on \"Statically type & compile Python code\" | Hashnode"
description: "Discussion on \"Statically type & compile Python code\". You can statically type and compile Python code using Python Type annonations, mypy and Nuitka."
url: "https://hashnode.com/posts/statically-type-compile-python-code/633ea36277677a17c1fedb0e"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Statically type & compile Python code](https://blog.adham.salama.dev/statically-type-compile-python-code?utm_source=hashnode&utm_medium=feed)

You can statically type and compile Python code using Python Type annonations, mypy and Nuitka.

Oct 6, 2022 · 3 min read · blog.adham.salama.dev  
Updated Nov 18, 2022  
Read the article

-   [#python](https://hashnode.com/tag/python)
-   [#python3](https://hashnode.com/tag/python3)
-   [#static-code-analysis](https://hashnode.com/tag/static-code-analysis)

## Written by

[Adham Salama](https://hashnode.com/@adhamsalama)

@adhamsalama · Cairo, Egypt

  
[View profile](https://hashnode.com/@adhamsalama)

Software Engineer

A backend software engineer writing about backend stuff.

## Responses 2

Markdown supported · ⌘↵ to post

[Plamen Ivanov](https://hashnode.com/@scripto)

[Feb 26, 2023](https://hashnode.com/posts/statically-type-compile-python-code/633ea36277677a17c1fedb0e/comment/63fb27d6a13f5e02f6797735)

I have tested the nuitka with primes of 100000, and the run time of python and compiled code was nearly 2 min difference. I think this would be very helpful working with pandas and numpy.

[Feb 26, 2023](https://hashnode.com/posts/statically-type-compile-python-code/633ea36277677a17c1fedb0e/comment/63fb27d6a13f5e02f6797735#reply-63fb2973a13f5e02f6797777)

Great!

I think using pypy would make it even faster!

[Plamen Ivanov](https://hashnode.com/@scripto)

[Feb 26, 2023](https://hashnode.com/posts/statically-type-compile-python-code/633ea36277677a17c1fedb0e/comment/63fb27d6a13f5e02f6797735#reply-63fbbc4ca13f5e02f6798a8e)

[Adham Salama](https://hashnode.com/@adhamsalama) wow, I tested pypy. The run time was ~3x faster than nuitka 🤯

[Adham Salama](https://hashnode.com/@adhamsalama)

[Feb 26, 2023](https://hashnode.com/posts/statically-type-compile-python-code/633ea36277677a17c1fedb0e/comment/63fb27d6a13f5e02f6797735#reply-63fbbc86a13f5e02f6798a9a)

[Plamen Ivanov](https://hashnode.com/@scripto) Yeah, pypy is very fast indeed!

[Islam Abdelfattah](https://hashnode.com/@i350)

[Oct 29, 2022](https://hashnode.com/posts/statically-type-compile-python-code/633ea36277677a17c1fedb0e/comment/635d9f91b7bb8c3f4ee41c2d)

1- What is the benefit of compiling code? We already gained the benefit of types validation by mypy without compiling?

2- How can we run the compiled code?

[Adham Salama](https://hashnode.com/@adhamsalama)

[Oct 29, 2022](https://hashnode.com/posts/statically-type-compile-python-code/633ea36277677a17c1fedb0e/comment/635d9f91b7bb8c3f4ee41c2d#reply-635db459b7bb8c3f4ee41ca5)

1- We get better performance. 2- It's in the article.
