365 karma · joined October 7, 2024
https://retro64.altervista.org/blog/garbage-collection-commo...
Which would limit the loop to 1 + 2 + 4 ... 128 = 255. You could start off with this, but making it work and filling exactly 8000 might be too complicated.
[N3322] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3322.pdf
Also I doubt that a quantum algorithm is possible that provably solves the Navier-Stokes equations with known boundary and initial conditions. At least you need some discretization, and maybe you can get a quantum algorithm that provably converges to the real solution (which alone would be a breakthrough, I believe). Then you need some experimental lab setup with well controlled boundary and initial conditions that you can measure against.
In any case the validation would be at a very different standard compared to verifying prime factorization. At most you can gain confidence in the correctness of the simulation, but never absolute certainty.
3^N <= 2^M
log(3^N) <= log(2^M)
N*log(3) <= M*log(2)
log(3)/log(2) <= M/N
where M/N is the bits per ternary digit.1. They are working from Monday to Saturday. They can't take Saturday off, so they hire a care assistant to take care of their grandma on Saturdays, they happen to hire each other.
2. They are working from Monday to Friday. They take care of their own grandma over the weekends.
Scenario 1 adds more to the national GDP.
edit: Oh, it uses `signal.set_wakeup_fd`, interesting.
https://docs.python.org/3/library/signal.html#signal.set_wak...
edit2: it looks like the fd comes from a self-socket, but yeah, it's the same approach. The function is even called `_make_self_pipe`.
https://github.com/python/cpython/blob/bf21e2160d1dc6869fb23...
import asyncio
import os
import signal
import sys
async def get_stdin_reader():
loop = asyncio.get_running_loop()
reader = asyncio.StreamReader()
protocol = asyncio.StreamReaderProtocol(reader)
await loop.connect_read_pipe(lambda: protocol, sys.stdin)
return reader
async def amain():
print(f'pid: {os.getpid()}')
sig_queue: asyncio.Queue[None] = asyncio.Queue()
def sig_handler() -> None:
sig_queue.put_nowait(None)
loop= asyncio.get_running_loop()
loop.add_signal_handler(signal.SIGUSR1, sig_handler)
reader = await get_stdin_reader()
task1 = loop.create_task(reader.read(1))
task2 = loop.create_task(sig_queue.get())
pending = {task1, task2}
while True:
done, pending = await asyncio.wait(pending, return_when=asyncio.FIRST_COMPLETED)
if task1 in done:
task1 = loop.create_task(reader.read(1))
pending.add(task1)
print('got char on stdin')
if task2 in done:
task2 = loop.create_task(sig_queue.get())
pending.add(task2)
print('got signal')
asyncio.run(amain())`chroot`, the function, has probably some baggage that makes it impossible to enable straight from an unprivileged program? Anyway, a chroot-like program seems to be implementable on top of user namespaces. Rootless docker is mostly that, with more namespace and cgroup isolation.
using snd_pcm_T = std::unique_ptr<
snd_pcm_t,
decltype([](void* ptr){snd_pcm_close(ptr);})
>;
auto pcm_handle = snd_pcm_T(snd_pcm_open(...));
The lambda in decltype is C++20, otherwise the deleter type could be declared out-of-line.Rust decided to have more restrictive generic programming, with the benefit of early diagnostic of mistakes in generic code. C++ defers that detection to instantiation, which allows the generics to be more expressive, but it's a tradeoff. But this is an entirely different design decision to lifetime tracking.
I recently started using this pattern for pytest equality assertions, as pytest helpfully produces a detailed diff on mismatch. It's not perfect, as pytest doesn't always produce a correct diff with this pattern, but it's better than some alternatives.
Users normally place their icons using a given, single resolution, so that would only give you one initial saved icon position. You need some heuristic when the user first changes resolution with that icon present on the desktop.