You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/learn/migration-guides/python-to-rust/index.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,7 +88,7 @@ As you can see, **everything comes with Rust**. There's no decision fatigue arou
88
88
Many Python developers don't have a *single* reason to migrate to Rust; it's rather a combination of factors:
89
89
90
90
1. Developers interested in Rust are likely willing to understand systems programming concepts.
91
-
They outgrew Python's limitations and are looking for more control over performance and memory management.
91
+
They outgrow Python's limitations and are looking for more control over performance and memory management.
92
92
93
93
2. Python developers often long for stronger type guarantees.
94
94
They appreciate Rust's static type system and the "reliability" that comes with it.
@@ -102,13 +102,13 @@ While Python is very readable and great for prototyping, you often hit scaling c
102
102
103
103
Python's Global Interpreter Lock (GIL) limits true parallelism.
104
104
Past a certain point, this makes it challenging to fully utilize multi-core systems.
105
-
There is a version of Python without the GIL, but it [doesn't solve the performance issues yet](https://news.ycombinator.com/item?id=41677131).
105
+
There is an upcoming version of Python without the GIL, but it [doesn't solve the performance issues yet](https://news.ycombinator.com/item?id=41677131).
106
106
107
-
If your workloads are I/Obound, [asyncio](https://docs.python.org/3/library/asyncio.html) is great and can get you very far.
107
+
If your workloads are I/O-bound, [asyncio](https://docs.python.org/3/library/asyncio.html) is great and can get you very far.
108
108
In this case, you might not need to switch for performance reasons alone.
109
109
110
-
However, if your workload is CPU-intensive that's a different story.
111
-
That's where teams often have to resort to complex workarounds involving multiple sub-processes or fall back to C extensions, which are a security risk and hard to maintain on multiple platforms (except if you use containers).
110
+
However, if your workload is CPU-intensive, that's a different story.
111
+
That's where teams often have to resort to complex workarounds involving multiple sub-processes or fall back to C extensions, which can be a security risk and are hard to maintain on multiple platforms (except if you use containers).
112
112
I've hit that glass ceiling many times in Python, and it has never been fun.
113
113
Typically, you run into bottlenecks at the exact worst possible time: when your application is under heavy load and in production.
114
114
Those are the days you wish for more headroom, but you spend your time firefighting and monkey-patching your architecture to squeeze out every last bit of performance.
@@ -126,15 +126,15 @@ Or you add the famous `Any` type or a `# type: ignore` comment just to make the
126
126
I don't blame you.
127
127
128
128
As developers it requires discipline to add and maintain type hints consistently, which can be challenging in large codebases.
129
-
And even if you do, your colleagues might not, which can lead to discussions about typesafety and code quality that can be frustrating and unproductive.
129
+
And even if you do, your colleagues might not, which can lead to discussions about type safety and code quality that can be frustrating and unproductive.
130
130
Furthermore, adoption is inconsistent across the Python ecosystem (I'm looking at you, third-party libraries).
131
131
As a consequence, large Python applications can become difficult to maintain and refactor confidently.
132
132
133
133
From my experience, there is a breaking point around the 10-100k lines of code mark where the lack of type safety becomes a significant liability.[^1]
134
134
135
135
[^1]: See discussions on large-scale Python applications on [Reddit](https://www.reddit.com/r/Python/comments/a7zrjn/why_do_people_say_that_python_is_not_good_for/) and [HN](https://news.ycombinator.com/item?id=25073308).
136
136
137
-
Overall, we see more and more Python code that's written with type-safety in mind, but it's a slow and tedious battle, that consumes a lot of time and energy.
137
+
Overall, we see more and more Python code that's written with type-safety in mind, but it's a slow and tedious battle that consumes a lot of time and energy.
138
138
In Rust, types are front and center, and the compiler enforces them. You simply can't forget to handle any edge cases.
139
139
Initially, that is super annoying, but the payoff when you're knee-deep in a large refactor is priceless.
140
140
I have done many large refactors in both languages, and I will take the Rust developer experience any day of the week.
@@ -163,7 +163,7 @@ I've seen people double-check that the monitoring is working because it looked t
163
163
164
164
### In Summary
165
165
166
-
None of the above problems are dealbreakers for Python and you can get a lot of mileage out it, but when you hit problem after problem, you start looking for alternatives.
166
+
None of the above problems are dealbreakers for Python and you can get a lot of mileage out of it, but when you hit problem after problem, you start looking for alternatives.
167
167
A lot of Rust developers started out as Python developers, and I think you can now see why.
168
168
Rust just resolves some of the most common pain points of Python at the cost of a steeper learning curve and a smaller ecosystem.
169
169
If that tradeoff is worth it for you is something only you can decide.
0 commit comments