Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
lauriat
searching Neon…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
6 ms
·
1.
▲
by
lauriat
5y ago
There is https://github.com/lauriat/funct which has some of those higher level functions.
2.
▲
by
lauriat
5y ago
Neat. There's also sc but I wanted to make something light and simple.
3.
▲
Show HN: Texel – CLI tool for viewing spreadsheets
(github.com)
23 points
by
lauriat
5y ago
|
4 comments
4.
▲
by
lauriat
6y ago
Thanks for the feedback! Redesigned swiss-army-knife is well put. I’m sure Array’s not for everyone, but for some, including me it’s a nifty tool. I don’t expect people to memorise all the features of the library - the aim was to name and d
5.
▲
by
lauriat
6y ago
Fair enough. Readability is subjective but I understand the sentiment. Constructing list comprehensions of such long chained expressions can be rather tedious and error prone, though (as your example shows).
6.
▲
by
lauriat
6y ago
That's why the A is capitalised ;)
7.
▲
by
lauriat
6y ago
cheers!
8.
▲
by
lauriat
6y ago
I agree, and yes, the line may be a bit excessive. The idea of Arrays is not just to cram a heap of functions to a single line. The readability (at least to me) is improved even with e.g. a single map arr.map(func) vs. list(map(f
9.
▲
by
lauriat
6y ago
If you're doing matrix multiplication or other math operations on fixed size sequences, you shouldn't. If, however, you need the dynamic nature of the built-in list or functional methods with a touch of numpyness, you should give
10.
▲
by
lauriat
6y ago
Fair enough, the example is a bit exaggerated. You could implement it with comprehensions all(func3(y) for y in (func1(x) for x in zip(a, b)) if func2(y)) It most likely is a bit faster, but I wouldn't say it's more readabl
11.
▲
by
lauriat
6y ago
You can already do that with d.get("non_existant_key", default)
12.
▲
by
lauriat
6y ago
My explanation was pretty poor, let me rephrase For example, when calling Array((x, y), (z, w)).index((z, w)) the following piece of code is executed bool(Array((x, y)).__eq__((z, w))) = bool(Array(False, False)) If __bool_
13.
▲
by
lauriat
6y ago
I understand the unpythonic nature of Arrays may startle some hardcore pythonistas, but ability to chain functions was one of the main reasons why I wrote the package as I find nested function calls ugly and sometimes rather hard to deciphe
14.
▲
by
lauriat
6y ago
Thanks! Good point. However setting def __bool__(self): return self.nonEmpty would mess up certain methods e.g. .index for nested Arrays as __eq__ is computed elementwise and bool(Array(False, False)) would evaluate to True. Maybe a
15.
▲
by
lauriat
6y ago
Thank you for taking the time to check it out! Naturally if you're dealing with big arrays/tensors, numpy is the best choice for operating on sequences. However, ndarrays have downsides for certain use cases - as ndarrays are fixe
16.
▲
Show HN: Array – A Better Python List
(github.com)
87 points
by
lauriat
6y ago
|
66 comments