所以我试图学习计算机的各种组件的性能指标,如 L1 缓存、L2 缓存、主内存、以太网、磁盘等,如下所示:
Latency Comparison Numbers
--------------------------
L1 cache **reference** 0.5 ns
Branch mispredict 5 ns
L2 cache **reference** 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory **reference** 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 10,000 ns 10 us
Send 1 KB bytes over 1 Gbps network 10,000 ns 10 us
Read 4 KB randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
Read 1 MB sequentially from memory 250,000 …Run Code Online (Sandbox Code Playgroud) 有趣的是,Python 中的数字没有大小限制。我想了解这是如何在 python 中实现的?
这只是字节的问题吗?其他语言对 int、float 等类型有字节限制,而 python 则没有。
即使我的数量很小,因为此实现需要一些开销(与 Java、C# 等其他语言相比),是否会因此影响性能?
其他语言也可以通过添加新类型来实现此功能吗?或者是否存在与其他语言和 python 根本不同的东西,阻止它们实现此功能。