Skip to content

Commit 50a1a4d

Browse files
feat(ebook): add complex_list_ops to ebook
1 parent d3b274d commit 50a1a4d

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

ebook/chapters/third_party_chapters/non_categorized.tex

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,23 @@ \subsection{Text Analysis}
192192
>>> import nltk
193193
>>> nltk.download('averaged_perceptron_tagger')
194194
\end{lstlisting}
195+
196+
197+
\subsection{Complex List Ops}
198+
199+
In your day to day work you will very likely come across performance issues in Python.
200+
Sometimes it's a good idea to choose a different data structure than you have used to speed up certain operations.
201+
However, you may come across situations where this is even not enough.
202+
Instead of switching to another language like C, you may want to check out the \lstinline{blist} package first.
203+
\glqq The \lstinline{blist} is a drop-in replacement for the Python list that provides better performance when modifying large lists.\grqq
204+
Here is a small snippet illustrating the huge impact of using a \lstinline{blist} instead of a \lstinline{list}:
205+
206+
\lstinputlisting[caption=complex\_list\_ops.py]{../third_party/complex_list_ops.py}
207+
208+
\begin{lstlisting}[caption=Output of complex\_list\_ops.py]
209+
$ python complex_list_ops.py
210+
"Builtin" spend time: 24.61005
211+
"Blist" spend time: 4.675813
212+
\end{lstlisting}
213+
214+
\glqq The blist package also provides \lstinline{sortedlist}, \lstinline{sortedset}, [...] \lstinline{btuple} types\grqq , and much more.

ebook/python-snippets.epub

686 Bytes
Binary file not shown.

ebook/python-snippets.mobi

1.16 KB
Binary file not shown.

ebook/python-snippets.pdf

2.54 KB
Binary file not shown.

0 commit comments

Comments
 (0)