好的,我在python中有一些打开文件的代码 - >处理它 - >并将数据写入其他文件。
def ELECrypt(myFile, outFile, code):
Code = list(bytes(code,'utf-8'))
with open(myFile, 'rb') as bFil:
with open(outFile, 'wb') as bOutFil:
while True :
data = bytearray(bFil.read(CHUNK_SIZE))
if not data: break
processIt(data, Code)
bOutFil.write(data)
它工作正常,但速度太慢。 所以,我写了一个类似的C ++程序,我想知道是否有可能从python中调用它
#include <iostream>
#include <fstream>
using namespace std;
int CHUNK_SIZE = 1*1024*1024;
void ELECrypt(ifstream& myFile, ofstream& outFile, unsigned char Code[], int CodeLen){
unsigned char* fChunk = new unsigned char[CHUNK_SIZE];
int readCount;
while (myFile.read((char *)fChunk, CHUNK_SIZE) || myFile.gcount() > 0)
{
...Processing a data block
outFile.write((char *)fChunk, myFile.gcount());
}
delete [] fChunk;
}
是的 - 是的,我知道可能会有很多工作,但我甚至无法找到可以通过python传递给c ++扩展的参数的地方