News for hackers. Stuff that matters.
Re:Fastcore: A library that extends Python with new features by formerly_proven on Saturday September 05, 2020 @12:09PM (#24384593)
Using pickle for "Path.save/load" feels like a shortcut to me that is inappropriate for many circumstances, since loading a pickle in Python literally means running code from that pickle. It's basically eval(Path.read()). It's not the kind of trust relationship that I would typically expect from a load/save pair.

> Wait! What's going on here? We just imported pathlib.Path - why are we getting this new functionality?

If you are writing a library and this is part of your expose, think long and hard.

> Path.ls

Highly gimmicky, doesn't support globs. Arguments are "n_max, file_type and file_exts", in that order. n_max seems largely pointless for real programs and like a workaround for a poor REPL for interactive use. The difference between the last two arguments is that the first one also accepts mimetypes (does this call "file" on every file it sees?).

Arguably the signature of a "Path.ls" should rather look like "Path.ls(glob='<star>', <star>, files=True, dirs=True)" and it should probably not return a bunch of strings.

Re:Fastcore: A library that extends Python with new features by jph00 on Saturday September 05, 2020 @05:27PM (#24386966)
Look closer. It doesn't return strings.
Re:Fastcore: A library that extends Python with new features by formerly_proven on Sunday September 06, 2020 @07:18AM (#24390592)
Distinction without difference, since Path is just sugar around a string. Directory listing functions should generally return something that mimics dirent/WIN32_FIND_DATA to avoid double work. For example, filtering for file type can typically be done without an extra stat call per file.