3 ms·
My bad it's on the insertion side, you can O(1) insert into the middle of Array-likes like Set in JS (which I use in this lib), where I think Python is O(n) for
by _akhe 3y ago
My bad it's on the insertion side, you can O(1) insert into the middle of Array-likes like Set in JS (which I use in this lib), where I think Python is O(n) for all it's Array-likes. Think you can O(1) append to an Array though.
But there are at least a few other reasons Python is generally slower than JavaScript. It's popular in ML because it was popular in math, and it was popular in math because it's easy to teach in schools. People use Python for its ML libraries, and now its ML communities, not because it's a fast language - it isn't really. And has no browser implementation, so there are a few reasons I didn't choose Python.
Reading it again I think I understand what the other poster meant now, but they also said "multi-process has nothing to do with the language" when it does have a lot to do with scaling Node especially to handle concurrency. I did a little demo here a while ago to show what I mean, check out the browser tab example: https://github.com/bennyschmidt/simple-node-multiprocess https://github.com/bennyschmidt/simple-node-multiprocess
Thanks for your comments, I hate language vs language debates! :D
- selcuka 3y ago> you can O(1) insert into the middle of Array-likes like Set in JS Sets are supposed to retain the insertion order. I don't think you can insert into the middle, let alone in O(1) time (as they are hashmaps, not linked lists). > I hate language vs language debates! I wasn't trying to compare JS to Python. My aim was to clarify a misunderstanding re: data structures used.
- _akhe 3y agoIn the case of `Set` and `Map` they're keys though. It's sorted in that you can reference `data[1]` and get that element, but I don't know the keys are necessarily sorted. This guy says "V8 team explains how some memory optimization was done on its hashtable implementation for Map, Set, WeakSet, and WeakMap: Optimizing hash tables: hiding the hash code Based on 1 and 2: V8's Set and Map's get & set & add & has time complexity practically is O(1)." https://stackoverflow.com/questions/33611509/es6-map-and-set-complexity-v8-implementation https://stackoverflow.com/questions/33611509/es6-map-and-set...