同样的python代码,经过cython编译后运行,一般情况下也比用python解释器运行要快。
因为python解释代码,本质上就是一个for/switch,对字节码的逐条执行,相比机器语言, 使得CPU无法预判指令分支,也破坏指令缓存的局部化。
p1.py
/* | |
using official fcgi++ library | |
Reference to fcgi protocol at https://tools.ietf.org/html/rfc3875#section-6.2.1 | |
Build: g++ main.cpp -lfcgi++ -lfcgi -o main | |
Spawn: spawn-fcgi -a 127.0.0.1 -p 9105 -n -- main | |
*/ | |
#include <iostream> | |
#include <string> | |
#include <thread> |
#!/usr/bin/python | |
from scapy.all import * | |
import time, sys | |
pkts = rdpcap(sys.argv[1]) | |
clk = pkts[0].time | |
for p in pkts: | |
time.sleep(p.time - clk) | |
clk = p.time | |
sendp(p) |
# -------- | |
# Hardware | |
# -------- | |
# Opcode - operational code | |
# Assebly mnemonic - abbreviation for an operation | |
# Instruction Code Format (IA-32) | |
# - Optional instruction prefix | |
# - Operational code |
##git mergetool
In the middle file (future merged file), you can navigate between conflicts with ]c
and [c
.
Choose which version you want to keep with :diffget //2
or :diffget //3
(the //2
and //3
are unique identifiers for the target/master copy and the merge/branch copy file names).
:diffupdate (to remove leftover spacing issues)
:only (once you’re done reviewing all conflicts, this shows only the middle/merged file)
package main | |
import ( | |
"compress/gzip" | |
"io" | |
"net/http" | |
"strings" | |
) | |
type gzipResponseWriter struct { |