Pyston 改變方向,將主推模組載入的方式使用

Pyston 專案是一個想要提供更快速的 Python,而前陣子決定改變開發的方向:「Announcing 3.7-3.10 support and a new direction」。

本來的 Pyston-full 是直接修改 CPython 的 codebase 加速:

Our original product, which we’re retroactively calling Pyston-full, is a fork of the entire CPython codebase. Having users install a fully-custom version of Python lets us make changes across the Python implementation, leading to the most optimizations and largest speedups.

但這種方式的安裝與維護都需要另外搞,而且因為 ABI 不相容的問題,遇到一些套件可能會需要自己編 (甚至自己改?),不能直接用編好的 binary:

The flip side is that it is fairly intensive to set up. While we believe Pyston-full is one of the most highly-compatible alternative Python implementations available, it can be difficult to switch Python implementations regardless of the ease of use of either implementation. Compounded on this, we decided to break the ABI which requires users to recompile extension modules. In theory this is not a big deal, but in practice the lack of available binary packages is a significant disincentive to use an alternative implementation.

這樣雖然有 30% 的效能提昇,但對使用者的吸引力不高,所以打算要轉變方向,讓使用者更容易使用,這也是決定發展可以用 pip 安裝的 Pyston-lite 版本:

The sum of all of this was that while we were very happy to achieve a 30% speedup with Pyston-full, it was very difficult to get people to start using it. We decided to try a different form factor: a pip-installable extension module called Pyston-lite.

但效能的提昇就不像 Pyston-full 這麼高,Pyston-lite 只剩下 10% 了:

So while it’s a bit difficult to accept that we are now providing a 10% speedup instead of 30%, we’ve decided that it’s much more important to provide something that people are willing to use.

另外在文末有列出各版本的效能提昇 (與 CPython 3.8 比較),可以看到 CPython 3.11rc2 的提昇其實跟 Pyston-lite 差不多,除非 Pyston-lite 可以把效能疊加上去,不然就有點尷尬了:

但 Pyston 要支援 3.11 看起來會花不少功夫:

In the longer-term future we are planning to submit our JIT upstream as well, but we expect retargeting it to 3.11 to be significantly more work than the other versions due to the extensive amount of changes that were made to the interpreter in that version.

不過手上一些既有的東西好像可以掛上去測看看...

uBO Lite:另外一個方向的嘗試

兩個禮拜前在 Hacker News 上看到的東西,算是 uBlock OriginManifest V3 (MV3) 的另外一種嘗試:「uBlock Origin Lite: Description (github.com/gorhill)」,專案的說明在「uBO Lite (uBOL), an experimental permission-less MV3 API-based content blocker.」這邊。

先前在「因應 Manifest V3 而推出的 uBlock Minus (MV3)」這邊提到的 uBlock Minus 是在 MV3 環境下的一個嘗試,但這個版本只是把 MV3 做不到的事情先拔掉,所以缺了很多重要的功能,像是 cosmetic filtering (主要是針對瀏覽器不支援的 css selector,像是最近才剛支援的 :has(),而這些 css selector 對於選擇要幹掉的 html 元素很好用)。

uBO Lite 則是一個妥協,另外讓使用者對特定站台點選授權,而在這些特定授權的站台可以恢復到原來 MV2 時可以過濾的能力 (包含 cosmetic filtering 等等的能力):

但這個方案也是 Google 所樂見的,只要不方便就會讓使用者慢慢放棄。

目前的公告提到 MV2 只支援到明年一月,大概還有三四個月的時間,接下來 adblock 這塊應該會有很多新的方法陸陸續續冒出來...

改善內嵌 YouTube 影片的載入速度

YouTube 的 embed 會載入大量的元件,所以就有專案把對使用者沒有意義的元件都拔掉:「Lite YouTube Embed」。

從比較可以看出來 Lite YouTube Embed 下載的元件少很多:

當然在功能上有差異,不過基本的功能應該都沒問題...

雖然還是 JavaScript 實做,但可以看到實際的程式碼大概 40 行而已?(註解的行數大約是程式碼的兩倍):「lite-youtube-embed/src/lite-yt-embed.js」。

不過要注意的是,程式碼中用到 ES6 的 class 語法,所以如果要考慮到 IE11,應該是要打包轉換...

把本來 dehydrated 的 PPA 改成 dehydrated-lite

本來有做 dehydratedPPA (在「PPA for dehydrated : Gea-Suan Lin」這邊),後來在 17.10+ 就有更專業的人包進去了 (參考「Ubuntu – Package Search Results -- dehydrated」),為了避免名稱相同但是內容物差很多,我把 PPA 的名字換成 dehydrated-lite 了 (參考「PPA for dehydrated (lite) : Gea-Suan Lin」)。

然後 0.6.2 的 dehydrated 針對 ACMEv2 有修正,這在 0.6.1 時會產生 certificate 裡有多餘資訊 (而 PPA 版的 gslin/dehydrated 只會停留在 0.6.1),這點需要注意一下:

Don't walk certificate chain for ACMEv2 (certificate contains chain by default)

之後再找機會拔掉 gslin/dehydrated,也許會照著現在 APT 內的架構來做...

控制瀏覽器裡的 Web API

在「阻止网站调用不必要的你的浏览器 API」這篇裡面看到的,論文的作者發展了 ChromeFirefox 的延伸套件,可以控制瀏覽器內的 Web API。套件原始程式碼在 GitHubsnyderp/web-api-manager,頁面上有 Chrome 與 Firefox 延伸套件的連結可以直接安裝。

套件本身預設不會擋任何 Web API,但提供了三種不同的 Preset 讓你選 (Lite、Conservative 與 Aggressive),一般情況下用 Lite (擋掉 17 種 Web API) 就有不錯的效果了。另外也可以針對某些網域做另外的調整... (雖然還沒用過 XD)

直接抓 Google Chrome 上給的截圖:

這是個好東西啊,有些 API 出來擺明就是來追蹤使用者的... 關掉省麻煩 XD

VaultPress 的新方案

VaultPressWordPress 的付費服務,可以備份自己架設的 WordPress 站台。

剛剛看到新的方案出爐了:「Announcing Streamlined Plans — at Lower Prices」,Jetpack Personal 將本來的 VaultPress Lite 包在內,但是價錢更低了:

At $3.50 per month, the Jetpack Personal plan includes everything the old VaultPress Lite plan used to — at a price that’s 30% lower.

有在用的人記得進去更改方案,另外要注意生效時間,等原來 Lite 快到期再改。

Facebook 推出 Facebook Lite

Facebook 推出 Facebook Lite (Android):「Announcing Facebook Lite」。

與完整版的差異在於對網路的使用量會更低,以及使用的資源會更少:

Today we’re introducing Facebook Lite, a new version of Facebook for Android that uses less data and works well across all network conditions.

Facebook Lite is less than 1MB so it is fast to install and quick to load. It includes Facebook’s core experiences like News Feed, status updates, photos, notifications and more.

之前就先有先推出了,不過現在開放給更多地區使用:

Starting today, we are rolling out Facebook Lite in countries across Asia, and over the coming weeks Facebook Lite will be available in parts of Latin America, Africa and Europe.