Learning Cython Programming
暫譯: 學習 Cython 程式設計

Philip Herron

  • 出版商: Packt Publishing
  • 出版日期: 2013-08-24
  • 售價: $1,260
  • 貴賓價: 9.5$1,197
  • 語言: 英文
  • 頁數: 110
  • 裝訂: Paperback
  • ISBN: 1783280794
  • ISBN-13: 9781783280797
  • 已過版

相關主題

商品描述

Developers who like C/C++ will love the added dynamism of Cython. This practical guide gives you everything you need to start programming with Cython and enhancing your existing applications. It could change your working life.

Overview

  • Extend C applications with pure Python code
  • Expand low-level C open source projects with pure Python – Tmux
  • Get the most out of highly computational Python code using Cython
  • Integrate your C applications with Python Distutils and Automake/Autoconf

In Detail

Cython is a very powerful combination of Python and C. Using Cython, you can write Python code that calls back and forth from and to C or C++ code natively at any point. It is a language with extra syntax allowing for optional static type declarations. It is also a very popular language as it can be used for multicore programming.

Learning Cython Programming will provide you with a detailed guide to extending your native applications in pure Python; imagine embedding a twisted web server into your native application with pure Python code. You will also learn how to get your new applications up and running by reusing Python’s extensive libraries such as Logging and Config Parser to name a few.

With Learning Cython Programming, you will learn that writing your own Python module in C from scratch is not only hard, but is also unsafe. Cython will automatically handle all type-conversion issues as well as garbage collection on your code. You can also still write all your code in Python but have it compiled and called directly in C as if it was just another function or data.

This book also demonstrates how you can take the open source project Tmux and extend it to add new commands directly in pure Python. With this book, you will learn everything you need to know to get up and running with Cython and how you can reuse examples in a practical way.

What you will learn from this book

  • Reuse Python logging in C
  • Make an IRC bot out of your C application
  • Extend an application to have a web server for rest calls
  • Use Cython against your C++ code
  • Reuse Python ConfigParser in C
  • Create Python bindings to native libraries
  • Learn about threading and concurrency related to the GIL
  • Expand Terminal Multiplexer Tmux with Cython

Approach

A practical and a fast-paced guide that gives you all the information you need to start programming using Cython.

Who this book is written for

This book is for developers who love C/C++ for low latency and speed but who also require the ability to add more dynamic features to applications both fast and reliably. It will also show you how you can get new applications off the ground by reusing Python libraries to get started.

商品描述(中文翻譯)

開發者如果喜歡 C/C++,將會喜愛 Cython 所帶來的額外動態性。這本實用指南提供了您開始使用 Cython 編程和增強現有應用程序所需的一切。它可能會改變您的工作生活。

概述
- 使用純 Python 代碼擴展 C 應用程序
- 使用純 Python 擴展低層次的 C 開源項目 - Tmux
- 利用 Cython 從高度計算的 Python 代碼中獲取最大效益
- 將您的 C 應用程序與 Python Distutils 和 Automake/Autoconf 整合

詳細內容
Cython 是 Python 和 C 的一個非常強大的結合。使用 Cython,您可以在任何時候編寫 Python 代碼,並原生地從 C 或 C++ 代碼之間進行回調。這是一種具有額外語法的語言,允許可選的靜態類型聲明。它也是一種非常受歡迎的語言,因為它可以用於多核心編程。

學習 Cython 編程將為您提供一個詳細的指南,以純 Python 擴展您的本地應用程序;想像一下,將一個 Twisted 網絡伺服器嵌入到您的本地應用程序中,使用純 Python 代碼。您還將學習如何通過重用 Python 的廣泛庫(例如 Logging 和 Config Parser 等)來啟動和運行您的新應用程序。

通過學習 Cython 編程,您將了解到從頭開始用 C 編寫自己的 Python 模塊不僅困難,而且也不安全。Cython 將自動處理所有類型轉換問題以及代碼的垃圾回收。您仍然可以用 Python 編寫所有代碼,但可以將其編譯並直接在 C 中調用,就像它只是另一個函數或數據一樣。

這本書還展示了如何將開源項目 Tmux 擴展,以直接在純 Python 中添加新命令。通過這本書,您將學到所有您需要知道的內容,以便開始使用 Cython,並了解如何以實用的方式重用示例。

您將從這本書中學到的內容
- 在 C 中重用 Python 日誌
- 將您的 C 應用程序製作成 IRC 機器人
- 擴展應用程序以擁有用於 REST 調用的網絡伺服器
- 在您的 C++ 代碼中使用 Cython
- 在 C 中重用 Python ConfigParser
- 創建 Python 與本地庫的綁定
- 了解與 GIL 相關的線程和並發
- 使用 Cython 擴展終端多路復用器 Tmux

方法
這是一本實用且快速的指南,提供了您開始使用 Cython 編程所需的所有信息。

本書的讀者對象
這本書是為那些喜愛 C/C++ 以獲得低延遲和速度的開發者而寫的,但他們同時也需要能夠快速且可靠地為應用程序添加更多動態功能。它還將向您展示如何通過重用 Python 庫來啟動新應用程序。