Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
ynik
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
10 ms
·
61.
▲
by
ynik
3y ago
That depends on the hash table implementation and the distribution of the integers. For the commonly used hash tables with prime size that use modulo to turn the hash code into a slot index, an identity hash for integers is usually fine (un
62.
▲
by
ynik
3y ago
AFAIK Python strings cache their hash value. All the hash table lookups for object properties should be compile-time constant strings that reuse the string object, and thus also reuse the cached hash value. It may take 11 hash computations
63.
▲
by
ynik
3y ago
You can. The last byte of an emoji is never the same as 'a'. UTF-8 is self-synchronizing, a trailing byte can never be misinterpreted as the start of a new codepoint. This makes `memmem()` a valid substring search on UTF-8! With m
64.
▲
by
ynik
3y ago
But it's quite unclear what they are currently doing. Literally translating what you are describing: template<char... FILE> struct magic { }; magic<__FILE__> m; This does not compile with gcc, and std::source
65.
▲
by
ynik
3y ago
If the `const char*` is a compile-time value, you can get its size via `std::char_traits<char>::length()`. Here I could get `magic_functor<std::source_location::file_name()>::type` to work on MSVC: https://godbolt.org
66.
▲
by
ynik
3y ago
`std::source_location` does not have to be a function argument. It can also be used in an NSDMI, in which case it ends up being instantiated whenever the NSDMI is used, i.e. at every aggregate initialization site. https://godbolt
67.
▲
by
ynik
3y ago
> generally when two satellites collide some debris can be shot at a higher orbit which will take forever (or will not) reenter atmosphere. The lowest point of the new orbit (perigee) is guaranteed to be no higher than the point of colli
68.
▲
by
ynik
3y ago
Stop using Windows. It is foolish to assume that any data on a Windows machine can stay out of the Microsoft cloud. E.g. Microsoft Edge on first launch can import bookmarks+stored passwords from Firefox (AFAIK without any user interaction,
69.
▲
by
ynik
3y ago
That's a common feature nowadays, not unique to Java. C# has had `enumerable.AsParallel()` since .NET 4.0 (2010). Rust has rayon `input.par_iter()`.
70.
▲
by
ynik
3y ago
Making an svn branch and scrapping it, indeed never was a big deal. Making an svn branch and merging it, now that was a huge issue. "svn merge" sucked compared to "git merge". For the project I was managing back in 2007
71.
▲
by
ynik
3y ago
The way I got into git was: I was working on a project using Subversion and wanted to be able to work on train rides (and internet connectivity on trains wasn't a thing back in 2007). Initially I tried SVK, but I found that git-svn act
72.
▲
by
ynik
3y ago
python3 in 2008 was practically unusable. It was incompatible, none of the libraries on pypi supported it; and it was extremely hard to write a code base that was compatible with both python2.6 and python3.0 at the same time, so almost none
73.
▲
by
ynik
3y ago
In fact, it prevents very few race condition bugs. Even inside a C extension where the Python API feels like it gives you control over when you release the GIL (with functions you'd have to call explicitly to release the GIL), it turns
74.
▲
by
ynik
3y ago
The standard libraries on Windows don't involve libc. The Windows APIs look rather different, and in general are much more friendly to multi-threading. POSIX on the other hand tends to assume that the program is in control of everythin
75.
▲
by
ynik
3y ago
Yesterday's Windows 10 security updates did not include a new curl version; the curl included with Windows is still 8.0.1.
76.
▲
by
ynik
3y ago
I wonder why exactly this attack can't be pulled off with HTTP/1.1 and TCP RST for cancellation. It seems that (even with SYN cookies involved) an attacker could create new connections, send HTTP request, then quickly after send a
77.
▲
by
ynik
3y ago
Right now FFI + ctypes has one big advantage: it supports true parallelism with GIL-per-subinterpreter in Python 3.12. AFAIK all the higher-level binding libraries/tools (PyO3, pybind11, nanobind, Cython) don't support this yet; a
78.
▲
by
ynik
3y ago
The Python<'_> type appearing as a parameter means the caller has already acquired the GIL for you. The GIL is held when Python calls into extension modules, and PyO3 doesn't automatically release it (but you can do so yours
79.
▲
by
ynik
3y ago
Fun fact: NTFS on C: is extra slow. A Python script creating 10000 empty files takes 1.2s on C:, but only 0.5s on D:. Both are NTFS partitions on the same SSD, both partitions are using the default settings. (but the defaults differ: on the
80.
▲
by
ynik
3y ago
Because in our case, all threads would be running a mixture of Python and C++. Our core data structure is implemented in C++, large (often >10 GB), and can be shared across threads (thread safe, usage is mostly read-only). But we have lo
81.
▲
by
ynik
3y ago
However if one is using C++/Rust anyways, then it's a good idea to stay away from Cython. From afar, Cython seems like a viable solution for Python/C++ interop. But the details get messy: you need to clone the .h headers into
82.
▲
by
ynik
3y ago
Not for pure python code; but there's massive advantages for mixed C(++) and Python: I can now have multiple sub interpreters running concurrently and accessing the same shared state in a thread-safe C++ library. Previously this requir
83.
▲
by
ynik
3y ago
"2 extra calls" is a weird metric here. Some calls are vastly more expensive than others. Syscalls come with a significant cost, encoding conversion of short strings (esp. filenames) does not. Hiding just the syscalls behind an ab
84.
▲
by
ynik
3y ago
Turing completeness doesn't have to come from a single feature, it often comes from a combination of features. e.g. the interaction between subtyping (e.g. inheritance) and generics (with variance) is tricky: https://www.cis
85.
▲
by
ynik
3y ago
A GC-free systems language isn't just for OS kernels. Rust's main use case was to replace C++ components in firefox. This wouldn't have been possible with a language that brings along its own GC, as Firefox already has a JS G
86.
▲
by
ynik
3y ago
How do you decide whether an UB-optimization is insane or not? "I know it when I see it" may work for lawmakers, but it's not good enough for compiler developers. Because if you want to disable all UB-based optimizations, the
87.
▲
by
ynik
3y ago
At least in clang, your variant is not any better: uninitialized reads return the special value `undef`, which the compiler can constant-propagate to both uses of `sparse_val`. But then each `undef` can turn to a different value at each use
88.
▲
by
ynik
3y ago
It's because accessing uninitialized memory is not UB in clang. From clang's point of view, a read from uninitialized memory returns the special value `undef`. Many operations applied to `undef` also return `undef`, but some (e.g.
89.
▲
by
ynik
3y ago
Yes, I supposed you could compile rust to .NET if you boxed everything (including simple integer fields, to allow taking their address as &i32) and used inheritance hierarchies for enums. Though that approach will still fail as soon as
90.
▲
by
ynik
3y ago
.NET has three main types of pointers: 1. unmanaged pointers (C# syntax: T*, C++/CLI syntax: T*): these are the same as C pointers: can be converted to/from integers, cast arbitrarily, pointer arithmetic can be used. The garbage c
More ›