Live data from Hacker News

Why I Use Nim instead of Python for Data Processing

benjamindlee.com

181–183 of 183 posts

Re: Why I Use Nim instead of Python for Data Processing

#181

Earlier quoted context omitted.

Yeah should really be "Why I don't use Python for Data Processing". I would consider Typescript as an alternative too which I'm sure would get a similar speedup. Also I don't know how anyone could design a language in the 21st century and make basic mistakes like this: > Nim treats identifiers as equal if they are the same after removing capitalization (except for the first letter) and underscore, which means that yo…

I wish this tired, boring argument didn't derail every conversation that remotely mentions Nim. See: literally every past HN post with "Nim" in the title. Nim's underlying, perhaps understated philosophy is that it lets you write code the way you want to write code. If you like snake case, use it. If you want camel case, sure. Write your code base how you want to write it, keep it internally consistent if you want, o…

> then the people that have never actually written code in Nim would be whining about that convention

Spot on. I wrote plenty of Nim and the style-insensitivity is a feature and not a bug.

Not allowing the use of 3 different variables named userName, user_name and username only encourages readable and robust code.

Re: Why I Use Nim instead of Python for Data Processing

#182
post #23

Earlier quoted context omitted.

Python is indeed slow, but why would anyone ever use php as a comparison point? And for data processing of all things ... Php is also very slow, on top of being many other kinds of unpleasant and broken.

PHP has a proper JIT compiler on its reference implementation.

> PHP has a proper JIT compiler on its reference implementation.

That doesn't make it fast at all. Just faster than if it wasn't jitted.

And that certainly does not eradicate the vast ocean of other problems php has, the first of which being that is was never, ever "though out" and instead grew like a cancerous mushroom.

Re: Why I Use Nim instead of Python for Data Processing

#183

Earlier quoted context omitted.

And reading the file as binary. There's a lesson about the overhead of unicode strings here ;) Your first example takes 3.1 seconds, my previous comment takes 2.3 seconds, this one takes 1.4 seconds. start = time.perf_counter() with open("orthocoronavirinae.fasta", "rb") as f: total = sum(map(lambda s: 0 if s[0]==65 else s.count(b"G") + s.count(b"C"), f.readlines())) end = time.perf_counter() print(total, " total") p…

This is good too. I would use a generator expression instead of the map though probably.

map is a generator
Post reply on HN