Skip to content

Instantly share code, notes, and snippets.

View integer_demotion.nim
proc foo(x: int8) = discard
proc bar(x: range[0'i8..1'i8]) = discard
var x =
echo compiles(foo(x)) # false
echo compiles(bar(x)) # true
View stats2.txt
NOTE: The imports are found by simple walking throught the AST and looking after `nkFromStmt` and `nkImportStmt` nodes.
The stdlib modules are identified by simple string comparisions.
This method is not entirely accurate, but it does give some indication of which modules are used and which are not.
File imports (tot: 14078)
0 volatile
0 db_odbc
0 asyncftpclient
0 punycode
0 ssl
View itrs.nim
import typetraits
iterator foo(i: int): int {.closure.} =
yield i + 1
yield i + 2
let f = foo
echo f(1) # 2
echo f(2) # 4
View times_bench.nim
import random, times
var input = newSeq[string]()
for _ in 1..100_000:
var sum = 0'i64
let before = getTime()
for str in input:
GULPF / stats.txt
Created Apr 28, 2018
Nim stdlib usage for top 1000 starred GitHub projects
View stats.txt
Number of files that imports the module (~15000 files total)
1 oswalkdir
1 rstgen
1 ftpclient
1 distros
1 strmisc
2 rlocks
2 lenientops
2 unidecode
3 httpserver