Skip to main content

make all python script as c extention with cython

Project description


透過 cython 將 script 轉換成 c 模組
加快執行速度, 使源始碼更難破解.....

轉換過程會有一些之 error 被檢查出來
變數未定義, 語法不正確等...
因為要先轉換為 C,所以一些不常跑到的程式碼
像一些測試用的,就不能被轉換
另外一些使用到內建的變數如 __file__ 的檔案也不適合轉換
列在 keep_source 的項目裡就會保留避免轉換成 c 模組

tab 和 空白在同一個檔案也不能混用
如果用混用到請將少數的部份修正

一些如 config 的檔案不希望在解壓時覆蓋到原本修改好的設定
設定在 exclude 裡面

因為使用 c 語言而且使用了最佳化的選項
因此 20 個檔案大約需要 5 分鐘轉換的時間

cython 可以混合使用 python 語法和 cython 語法
即使不使用 cython 的語法也可以
使用 cython 語法可以加速運算

另外 cython 可以控制 gil lock
可以在安全的範圍內釋放 gli
with nogil:
' do something '

使用 cython 執行速度可以和 c 一樣快
http://blog.csdn.net/gzlaiyonghao/article/details/4561611


1. 在 Windows 中如果有安裝 MSVC 2008 以外的版本
要先準備好開發環境
例如:

"%VS100COMNTOOLS%vsvars32.bat"
set DISTUTILS_USE_SDK=1
set MSSdk=1

2. 執行 python cython_setup.py build_ext --inplace
沒有錯誤的話會產生一個 zip

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py-ace-0.0.3.zip (8.0 kB view details)

Uploaded Source

File details

Details for the file py-ace-0.0.3.zip.

File metadata

  • Download URL: py-ace-0.0.3.zip
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for py-ace-0.0.3.zip
Algorithm Hash digest
SHA256 8606a157e78075071b79e64da46b0313e9f5bb49a8237ece0d2532f5a9f4bdc1
MD5 b485dd31a3b887abfbbb978391173ee8
BLAKE2b-256 97ca7e1ec0399a8a723f2260ce381f9d5ab89afa36da80f81bb0b27e4ba115d5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page