Fred

joined 8 months ago
[–] Fred@programming.dev 2 points 4 weeks ago (1 children)

I can’t remember if threads are core bound or not.

On Linux, by default they're not. getcpu(2) says:

   The getcpu() system call identifies the processor and node on which the
   calling thread or process is currently running and writes them into the
   integers pointed to by the cpu and node arguments.  ...

   The  information  placed in cpu is guaranteed to be current only at the
   time of the  call:  unless  the  CPU  affinity  has  been  fixed  using
   sched_setaffinity(2),  the  kernel  might  change  the CPU at any time.
   (Normally this does not happen because the scheduler tries to  minimize
   movements  between  CPUs  to keep caches hot, but it is possible.)  The
   caller must allow for the possibility that the information returned  in
   cpu and node is no longer current by the time the call returns.
[–] Fred@programming.dev 2 points 2 months ago

I'm using pylsp (python-language-server). My reason being a process of elimination. I also use mypy for type-checking, so even without considering the danger of allowing MS to entrench itself into my tooling, it didn't make much sense to use a tool built around pyright.

The ruff-lsp seems to only do the things that ruff is good at: linting, code formatting, auto-fix of certain issues, and I wanted more.

Since I saw that pylsp uses Jedi under the hood, and offered a mypy plugin, I felt that pylsp offer a superset of the features that the Jedi LSP has. In the end I'm happy with pylsp, and never tried Jedi LSP.

However: with the mypy plugin for pylsp, the memory usage kept growing to ridiculous amounts and getting killed, so I ended up disabling it. I had a look in their bug tracker Instead, I'm using flymake that triggers mypy on save, and that seems to work well. (I have a few changes on top of com4/flymake-mypy.el, because it leaves behind plenty of temporary files.)

That offers me:

  • jump to definition (using Jedi under the hood)
  • rename symbol (and then Jedi goes and rename uses of that symbol)
  • smart completion (eg. offers only variables in scope, or after a . only the instance members, etc.)
  • short documentation on hover
  • squiggly lines for errors found by flake8 or mypy
  • and a few more that I don't really notice

One thing I struggled with: where do you install the LSP? Using pipx for a user installation, or in a per-project venv? I did the latter, which works for me because I work on a small number of projects. That also means that mypy finds all the relevant third-party libraries in that venv. I wrote a bit of elisp that allow emacs to find the right mypy binary to check code.

[–] Fred@programming.dev 2 points 2 months ago

That was silly and clever, I enjoyed reading that :)

[–] Fred@programming.dev 49 points 3 months ago (1 children)

And Fabrice Bellard, the original author of ffmpeg, went on to create qemu which pretty much made open-source virtualization possible. Also TCC (even if I don't think that one is widely used), he established a world record for computing decimals of Pi using a single machine that had ~2000× less FLOPS than the previous record, and so much more...

[–] Fred@programming.dev 1 points 4 months ago

I think it has more to do with the fact Mother Nature is really inefficient and allocated much more DNA storage than necessary.

[–] Fred@programming.dev 2 points 4 months ago

Thank you for the pointers @e0qdk@reddthat.com

My use case certainly fall into that described by ESR, I only really need to understand markup that falls in the ASCII range and pass the rest unmodified

 

Hi,

I have to interface with systems that use iso-8859-x encoding (not by choice...), and I'm surprised that the following doesn't throw an error:

>>> str(bytes(range(256)), encoding="iso-8859-1", errors="strict")
'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0¡¢£¤¥¦§¨©ª«¬\xad®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ'

Bytes in the 0x80—0x9f range are not valid iso-8859-1, and I was expecting the above to raise a DecodeError of some sort; instead it looks like those are passed through.

I'm perfectly happy with this behaviour, I would like to make sure I can depend on it. Can I take an arbitrary byte buffer, decode as ISO-8859-1, and never get any error? Is it guaranteed to be lossless ?