小编pbp*_*pbp的帖子

接口(Ocaml)的假设不一致

我突然开始得到这个错误.我不知道如何诊断或修复它.我是否应该通过grep bar.ml检查每个Big_int函数以防止签名Big_int.mli

File "foo.ml", line 1, characters 0-1:
Error: The files /home/bar.cmi
       and /usr/lib/ocaml/big_int.cmi make inconsistent assumptions
       over interface Big_int
Run Code Online (Sandbox Code Playgroud)

ocaml compiler-errors

16
推荐指数
2
解决办法
6230
查看次数

禁用python的assert()而不使用-0标志

我正在从不同的软件中运行一个python脚本(它提供了一个python接口来操纵它的数据结构).

我正在优化我的代码速度,并希望看到我的断言对性能有什么影响.

我无法使用python -O.我有什么其他选项,以编程方式禁用python代码中的所有断言?变量__debug__(由-O标志清除)不能分配给:(

python debugging assert

10
推荐指数
1
解决办法
3014
查看次数

在Vim快速拉扯

我经常发现自己处于这样的境地:

line i want to yank
.
.
.
[cursor position]
Run Code Online (Sandbox Code Playgroud)

我想猛拉线并粘贴到[cursor position].

我这样做有[n]k,Y,[n]j,p.这是很多打字;).之前,我正在使用:

:[line number]Y
Run Code Online (Sandbox Code Playgroud)

然后粘贴,但这不适用于相对行号(relativenumber选项).

当相对数字为ON时,最快速的方法是做这种yanking /粘贴?

vim editing editor

10
推荐指数
4
解决办法
396
查看次数

快速的互联网爬虫

我想做大规模的数据挖掘.为此,我需要一个快速爬虫.我只需要下载一个网页,提取链接并递归地跟踪它们,但不要访问相同的网址两次.基本上,我想避免循环.

我已经在python中编写了一个爬虫,但它太慢了.我无法用它浸透100Mbit线.最高速度约为40 urls/sec.由于某种原因,很难获得更好的结果.这似乎是python的多线程/套接字的一个问题.我也遇到了python的gargabe收集器的问题,但这是可以解决的.CPU不是btw的瓶颈.

那么,我应该使用什么来编写尽可能快的爬虫,以及在爬行时避免循环的最佳解决方案是什么?

编辑:解决方案是组合multiprocessingthreading模块.为每个进程生成多个进程的多个进程,以获得最佳效果.在单个进程中生成多个线程是无效的,只有一个线程的多个进程会消耗太多内存.

python multithreading web-crawler web-mining

8
推荐指数
2
解决办法
6523
查看次数

当-g应该用于在OCaml中打印堆栈跟踪?

我正在尝试使用堆栈跟踪Printexc.get_backtrace,但我收到错误:

(Program not linked with -g, cannot print stack backtrace)

我正在编译:

ocamlfind ocamlc -g -o foo ... $(FOO_OBJS)

FOO_OBJS编译为: ocamlc -c $OBJ

怎么了?应该每个.cmo都编译-g

如果在没有编译的对象中发生异常,-g我会得到部分堆栈跟踪,或者根本没有堆栈跟踪?

debugging ocaml functional-programming compilation exception

8
推荐指数
1
解决办法
412
查看次数

ocaml中的哈希表

是否可以Hashtbl在Ocaml 中的相同哈希表()中存储不同的类型?哈希表真的只限于一种类型吗?

ocaml hashtable

7
推荐指数
1
解决办法
4227
查看次数

Ocaml哈希表中的平等

Ocaml中是否存在哈希表,==而不是=在测试键的相等性时使用?例如:

# type foo = A of int;;
# let a = A(1);;
# let b = A(1);;
# a == b;;
- : bool = false
# a = b;;
- : bool = true
# let h = Hashtbl.create 8;;
# Hashtbl.add h a 1;;
# Hashtbl.add h b 2;;
# Hashtbl.find h a;;
- : int = 2
# Hashtbl.find h b;;
- : int = 2
Run Code Online (Sandbox Code Playgroud)

我想要一个可以区分a和的哈希表b.那可能吗?

ocaml equality hashtable

6
推荐指数
1
解决办法
1197
查看次数

Ocaml int到二进制字符串转换

什么是最简单的转换Int32为二进制的方法?例如:-1 - >"\ 255\255\255\255"?

编辑:要使用extlib,请使用yum和toplevel安装它:

#use "topfind";;
#require "extlib";;
Run Code Online (Sandbox Code Playgroud)

ocaml type-conversion

6
推荐指数
2
解决办法
1904
查看次数

64位Linux上的32位进程的地址空间

这篇答案中,作者说: With the 64-bit x86_64 kernel, a 32-bit process can use the entire 4GB address space, except for a couple pages (8KB) at the end of the 4GB address space which are managed by the kernel.

这个内核管理内存的目的是什么?不应该在内核空间,以防止用户意外损坏?

linux memory 64-bit linux-kernel 32bit-64bit

5
推荐指数
1
解决办法
1954
查看次数

Ocaml 中的转义序列

Ocaml 中是否有标准方法可以将(例如)a\n(三字节字符串:)转换为0x61,0x5c,0x6e两字节字符串:0x61,0x0a

我的 Ocaml 程序可以接收带有转义字符的字符串,如何“取消转义”它们?

text ocaml escaping

5
推荐指数
1
解决办法
2586
查看次数