- 主題
- 数千万オーダーの文字列集合(およびマップ)を如何にサイズ効率良く表現するか、の話
- 諸事情で集合をメモリ上に保持したいことがあるが、サイズは節約したい
- 実際にはサイズのみを追求するのではなく、諸々のトレードオフを加味しつつバランスを取る
- 今回はそれを実現するための方法の一つである 簡潔データ構造 について説明する:
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
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 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
#!/usr/bin/env zsh | |
# This script prints a bell character when a command finishes | |
# if it has been running for longer than $zbell_duration seconds. | |
# If there are programs that you know run long that you don't | |
# want to bell after, then add them to $zbell_ignore. | |
# | |
# This script uses only zsh builtins so its fast, there's no needless | |
# forking, and its only dependency is zsh and its standard modules | |
# |
# -*- coding: utf-8 -*- | |
import unicodedata | |
for unicode_id in xrange(65536): | |
char = unichr(unicode_id) | |
normalized_char = unicodedata.normalize('NFKC', char) | |
if char != normalized_char: | |
if len(normalized_char) == 1: | |
print u'[%d] %s -> [%d] %s' % (unicode_id, char, ord(normalized_char), normalized_char) | |
else: |
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# This is a simplified implementation of the LSTM language model (by Graham Neubig) | |
# | |
# LSTM Neural Networks for Language Modeling | |
# Martin Sundermeyer, Ralf Schlüter, Hermann Ney | |
# InterSpeech 2012 | |
# | |
# The structure of the model is extremely simple. At every time step we |
パターンとはその言語が抽象化できなかった敗北の歴史である。 しかしどんなに優れた言語であってもあらゆる繰り返しに勝てるわけではない。 人は必ずメタ繰り返しを欲するからだ。 そしてそれはRustも例外ではない。
ここでは、OOPでも知られているパターンよりも、Rustに特有のパターンを思いつく限りまとめてみた。名前は適当。