What new features, tools, libraries (already implemented or being worked on) are the most useful for your work with Python? What are you the most excited about?
[1] https://peps.python.org/pep-0544/ [2] https://peps.python.org/pep-0646/ [3] https://github.com/pydantic/pydantic-core
So far I like:
- black autoformats my code swiftly
- ruff is fast and replaces multiple python linters
- pip-tools lets me manage multiple dependency specifications (local, prod, test) more sanely than manually syncing `pip freeze` with multiple requirements files.
- f-strings are nice improvement over .format calls, % string interpolation, string.Templates, etc.
- I appreciate pattern matching and case classes in Scala. I expect to like them using dataclasses and pattern matching PythonHuge fan of dataclasses as well.
Most of the python I write is functions / functional + data classes with type hinted everything and it seems to work nicely and make writing tests for functions very easy.
Using black, isort, mypy, pylint, pytest, makes every project simpler.
- numpy __array__ interface standardization (easy compatibility across a lot of numerical libraries, e.g. torch, awkward-array, zarr, jax.numpy, dask, xarray)
- the various jit compilers (e.g. numba, jax.jit, torch.compile)
- hw-accelerated functional programming style (e.g. functorch.vmap)
- pybind11 for easy af bindings to c++
- named dimensions for tensors
- pandas-compatible ecosystem (eg seaborn)
- pytrees
- pyenv
- mamba
What I really need, though, is a realtime successor to matplotlib with a much simpler interface/dsl. Haven't looked into plotly much but probably will try it soonish
plot.ly now has an API:
If it was easier to use virtual environments with PyCall I think I’d abandon matplotlib entirely.
I do like the := to save a few lines here and there.
3.10 does seem to run faster but maybe that is my imagination.
I wish more people would focus on writing good python.
it is not necessarily about type mismatch bugs per se, but more like without type information in the code I will misunderstand what kind of structure is passed in to a function, how to decompose it, what members the data has, what functions does it have, how do you spell them correctly, what elements to expect in dictionaries and what kinds of values do they have, and how can I make massive changes to code without knowing all those answers and expect it all to still work.
type annotations are solving a lot of those issues for me nicely, and the number of things that it doesn't solve well is decreasing with each version and the new features they are adding
If the function/method expects an int, string or complex type and I accidentally call it with the wrong type, resulting in an error, such as "can't add 1 to a string", or "can't access access that method because a string was passed".
>and what is good python vs bad python?
This is kinda of subjective but, for a start, don't just start at the type and do stuff until the bottom like a shell script. This is by far how I see most python scripts. All the other normal things. Don't repeat yourself (in moderation, a few times is OK). Keep it simple.
For example, clang and gcc can still compile C89 programs.
Hope they will add support for Unicode sets `\p{}`, subexpression calls, (*SKIP)(*F), etc. For now, the third-party `regex` module is handy for such features.
If I ever could wrap my brain around asyncio, it would be an appreciated third.
I never used the walrus operator, IIRC, and I find type hints not so useful. Somewhere in the future I will try to use them in APIs, they may have their benefit there.
Edit: I forgot enums. Not so new, but a must.
If you're developing something more complex, you might find the feature set too small, but you can get surprisingly far with what's there.
The benefits from its type safety and lack of boilerplate alone are enough to keep me using it in favour of anything else.
> Typer uses Click internally. That's the only dependency.
Pretty clever way to walk on giants shoulders!
first, *middle, last = range(10)
Set and dict comprehensions are also very useful but aren't that new anymore. Also, the Rich library is amazingly useful for all kinds of console applications.That in itself is a great feature.