小编Chu*_* Lu的帖子

读取用 Python Paramiko SFTPClient.open 方法打开的文件很慢

我正在尝试远程读取 netcdf 文件。
我使用 Paramiko 包来读取我的文件,如下所示:

import paramiko
from netCDF4 import Dataset

client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(hostname=’hostname’, username=’usrname’, password=’mypassword’)

sftp_client = client.open_sftp()
ncfile = sftp_client.open('mynetCDFfile')
b_ncfile = ncfile.read()    # ****

nc = Dataset('test.nc', memory=b_ncfile)
Run Code Online (Sandbox Code Playgroud)

但是运行速度ncfile.read()非常慢。

所以我的问题是:有没有其他方法可以远程读取 netcdf 文件,或者有什么方法可以加快速度paramiko.sftp_file.SFTPFile.read()

python ssh sftp paramiko netcdf

4
推荐指数
1
解决办法
4862
查看次数

模板的模板的参数类型推导规则是什么?

我有三个使用模板的函数:

template <template <typename...> class ContainerType, typename ItemType>
bool has_item(ContainerType<ItemType> items, ItemType target_item)
{
    // ...
}

template <template <typename...> class ContainerType, typename ItemType>
ContainerType<ItemType> filter(ContainerType<ItemType> items, const std::function <bool (ItemType)>& f)
{
   // ...
}


template <template <typename...> class ContainerType, typename ItemType>
bool is_vector(ContainerType<ItemType> items)
{
   // ...
}
Run Code Online (Sandbox Code Playgroud)

我认为编译器可以成功推断出参数类型,但似乎无法推断出第二个参数类型。

    std::vector<int> v = {1, 2, 3, 4, 5};
    std::cout << has_item(v, 1) << std::endl;     // OK
    
    auto less_four = [](int x) { return x < 4; };
    std::vector<int> v2 …
Run Code Online (Sandbox Code Playgroud)

c++ templates

2
推荐指数
1
解决办法
46
查看次数

标签 统计

c++ ×1

netcdf ×1

paramiko ×1

python ×1

sftp ×1

ssh ×1

templates ×1