这是一个你可能已经看到的各种形式的网络问题...总结在这里为你google搜索乐趣:-)
我有一个使用Microsoft的Visual Studio构建的项目,并使用boost(http://www.boost.org/)的功能.我已经让我的项目使用了一些只是标题的库(没有链接的二进制库).如何或在哪里可以获取其他库的Windows二进制文件?
我在 Windows 上运行的 C++ 程序中有一个结构,我想使用 ctypes 通过 Python 中的共享内存来访问该结构。例如:
#define MAX_ENTITIES 30
struct State
{
double x;
double y;
double z;
};
struct Stat
{
unsigned int numAvailable;
unsigned int numUsed;
};
struct TransferData
{
double exLg;
float other;
unsigned int more;
int more2;
unsigned char next;
bool statusReady;
Stat status;
State entities[MAX_ENTITIES];
};
Run Code Online (Sandbox Code Playgroud)
作为:
import ctypes
MAX_ENTITIES = 30
class State(ctypes.Structure):
_fields_ = [
('x', ctypes.c_double),
('y', ctypes.c_double),
('z', ctypes.c_double)
]
class Stat(ctypes.Structure):
_fields_ = [
('numAvailable', ctypes.c_uint),
('numUsed', …Run Code Online (Sandbox Code Playgroud) 当我在大量文件(>2GB)上运行 Inno Setup 时,需要很长时间才能运行。我相信它把时间花在了压缩上,这应该是 CPU 限制的,但它只使用了几个 CPU。有没有办法将其分散到(许多)更多核心?
具体来说,我正在使用这个boost-release 存储库,它有一个 Inno Setup 脚本,其中包括:
[Setup]
....
Compression=lzma2/ultra64
....
[Files]
Source: "boost_1.69.0/*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs ignoreversion
....
Run Code Online (Sandbox Code Playgroud)
Compil32.exe boost_installer.iss在具有 16 核和 32GB RAM (Azure F16s v2) 的计算机上,调用大约需要 25 分钟。
该文件集大约为 2.5GB,其中 2GB 是一组大约 300 个编译库。剩余的 500MB 是 60,000 个源文件。
当我从不同的 C 线程调用 C-API 的 Py_Finalize() 而不是我进行 python 调用时,我得到一个错误输出。
我看到的错误是:
Exception ignored in: <module 'threading' from 'C:\\Python34-32\\Lib\\threading.py'>
Traceback (most recent call last):
File "C:\Python34-32\Lib\threading.py", line 1289, in _shutdown
assert tlock.locked()
AssertionError:
Run Code Online (Sandbox Code Playgroud)
这只发生在 Python 3.X(用 3.4.2 测试)中,在 Python 2.7 中完全相同的代码没有任何问题。
这是一个最小的例子,它显示了在使用 C 线程时发生的情况,但不是当所有事情都发生在单个 c 线程上时:
#include <iostream>
#include <fstream>
#include <thread>
#include <cassert>
#include <Python.h>
void make_file()
{
std::fstream file("my_test.py", std::ios::out);
file <<
"import threading\n" <<
"def my_function():\n" <<
" pass\n" ;
file.close();
}
void exec()
{
PyGILState_STATE gstate = PyGILState_Ensure(); …Run Code Online (Sandbox Code Playgroud)