Write Elegant Concurrent Code in Python

  • R0
  • Day 3, 11:15‑12:00
  • Chinese talk w. English slides
  • Best Practices & Patterns
  • Intermediate

Writing concurrent program is hard; maintaining concurrent program even is a nightmare. Actually, a pattern which helps us to write good concurrent code is available, that is, using “channels” to communicate. This talk will share the channel concept with common libraries, like threading and multiprocessing, to make concurrent code elegant.

撰寫並行程式(concurrent program),例如多執行緒程式等,通常是困難的,而維護並行程式又是一場惡夢。其實有個方法可以寫出好的並行程式,只要使用 channel 做為溝通基礎,就可以寫出好維護的並行程式。這場演講會介紹如何在常見的函數庫,例如 threading、multiprocessing 等,中引入 channel 的概念,讓並行程式變得優雅。

Talk Detail

The concept of channel is from the CSP (communicating sequential processes). It's a famous mathematical theory of concurrent systems [1]. The Go (golang) uses it as its fundamental concurrency design [2]. The programmers can design simpler and more maintainable concurrent code with this theory [3]. Although the CSP is not a part of Python, but we still can use common libraries to realize CSP and write better concurrent code. This talk will introduce how to use common Python libraries to realize CSP. Channel 這個概念是來自於 CSP(communicating sequential processes),其是一個著名的並行系統(concurrent system)的數學理論 [1],並獲得 Go(golang)採用作為其並行設計的基礎 [2],使用此理論可以設計出較為簡單、好維護的並行程式 [3]。 雖然 Python 並沒有將 CSP 設計成語言的一部份,但我們仍可以利用常見函數庫內的工具實現 CSP,寫出更好維護的並行程式。這場演講會介紹利用 Python 常見函數庫實現 CSP 的方法。 [1]: https://en.wikipedia.org/wiki/Communicating_sequential_processes [2]: https://golang.org/doc/effective_go.html#concurrency [3]: https://golang.org/doc/faq#csp

Slides Link

Speaker Information

Mosky Liu

Mosky is Python Charmer at Pinkoi, works with colleagues to build the best online marketplace for unique gifts, and has love with Python and open source. more: mosky.tw.

Mosky 是 Pinkoi 的 Python Charmer,工作時和同事一起打造能夠買到獨特禮物的設計品購物平台,也是個熱愛 open source 精神的 Python 工程師。同時有在教授 Python 課程,也擁有數個 Python 專案,例如 ZIPCodeTW、Clime 與 MoSQL。也曾在許多研討會分享過,包含臺灣的 PyCon、COSCUP、TEDxNTUST,以及在日本、新加坡、香港、韓國等地的 PyCon。more: mosky.tw