Suzhou-Tongyuan / jnumpy

Writing Python C extensions in Julia within 5 minutes.
MIT License
234 stars 8 forks source link

search fast julia pkg server #39

Closed songjhaha closed 2 years ago

songjhaha commented 2 years ago

Implement https://github.com/johnnychen94/PkgServerClient.jl in python Works like:

In [1]: import jnumpy as np

In [2]: %time np.utils.registry_response_time()
CPU times: user 93.9 ms, sys: 20.9 ms, total: 115 ms
Wall time: 1.06 s
Out[2]: 
{'mirrors.bfsu.edu.cn': 0.385467529296875,
 'mirror.iscas.ac.cn': 0.7986209392547607,
 'mirrors.nju.edu.cn': 0.6467490196228027,
 'opentuna.cn': 0.4409325122833252,
 'mirrors.sjtug.sjtu.edu.cn': 0.3874180316925049,
 'mirrors.sustech.edu.cn': 0.6435022354125977,
 'mirrors.tuna.tsinghua.edu.cn': inf,
 'mirrors.ustc.edu.cn': 0.3986549377441406}

In [3]: %time np.utils.get_fast_mirror()
CPU times: user 86.6 ms, sys: 16.7 ms, total: 103 ms
Wall time: 1.07 s
Out[3]: 'https://mirrors.ustc.edu.cn/julia'

And set_julia_mirror(server) can set custom server url manually, or leave it empty to auto search fast server with get_fast_mirror()