Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 50a1a4d

Browse filesBrowse files
feat(ebook): add complex_list_ops to ebook
1 parent d3b274d commit 50a1a4d
Copy full SHA for 50a1a4d

File tree

Expand file treeCollapse file tree

4 files changed

+20
-0
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+20
-0
lines changed

‎ebook/chapters/third_party_chapters/non_categorized.tex

Copy file name to clipboardExpand all lines: ebook/chapters/third_party_chapters/non_categorized.tex
+20Lines 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

Copy file name to clipboard
686 Bytes
Binary file not shown.

‎ebook/python-snippets.mobi

Copy file name to clipboard
1.16 KB
Binary file not shown.

‎ebook/python-snippets.pdf

Copy file name to clipboard
2.54 KB
Binary file not shown.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.