HNHacker News
TopNewBestAskShowJobs

fabioz

117 karma · joined July 7, 2015

submissionscomments
fabioz··on Robot Framework: generic open source automation framework
Well, I bet that if they managed to be extremely unproductive with Robot Framework, they'd be equally unproductive with Python ;)

-- Robot Framework builds on top of Python and usually wraps python libraries -- such as Selenium or Playwright -- in a different API (which IMHO is usually easier to use) and provides some better reporting out of the box, so, I can't really see how the tool made people unproductive here...

fabioz··on Robot Framework: generic open source automation framework
Well, I don't know how things were back then, but Robot Framework had many changes in the latest times, so, it's possible things improved from there (thus your past experiences may not match the current state of affairs).

I'd say that it does have some quirks, but if well used it can be a good tool to have in your toolbox.

Disclaimer: I'm currently working on the Robot Framework Language Server extension for VSCode (by Robocorp, which uses Robot Framework to work with RPA -- albeit Robocorp supports well both Python as well as Robot Framework in the platform, there's a high traction on the Robot Framework side and many users enjoy it vs using just Python).

fabioz··on There are many ways to fail to read a file in a C program
Just as a note, the way that Python stores the items isn't always 4 bytes per char, it depends on the actual string contents.

I think that https://rushter.com/blog/python-strings-and-memory/ is a nice reference on that.

fabioz··on JEP proposed to target JDK 19: 425: Virtual Threads (Preview)
I must say that I definitely don't like the gevent monkey-patching myself -- I prefer to just use the different APIs, although yes, that can end up in a blocking call when there should be none, but that hasn't been a problem I've been bitten by so far -- although it's been a while since I had to use it too ;)
fabioz··on JEP proposed to target JDK 19: 425: Virtual Threads (Preview)
Well, whenever you add threads to the mix (native or virtual threads) if you don't design for it, I don't think things pan out properly (but I guess that I agree that if someone designed with native threads going for virtual threads where the same APIs can now make IO async switch threads it's probably easier to go that route).

I must say that the main usage I personally had of greenlets didn't have it in mind initially (it was used in an existing application where making the coloring wasn't really feasible as it was a huge app already and adopting green threads was much less work).

fabioz··on JEP proposed to target JDK 19: 425: Virtual Threads (Preview)
Well,

https://github.com/python-greenlet/greenlet

has been available for quite some time in Python (gevent probably being its most used flavor).

Note that it it actually predates the async/await approach which was incorporated into the Python language (so, in Python it was implemented as a third-party library -- even async/await had an implementation based on Python 2 using yield and some decorators: https://pypi.org/project/trollius/).

fabioz··on JEP proposed to target JDK 19: 425: Virtual Threads (Preview)
Well,

https://github.com/python-greenlet/greenlet

has been available for quite some time in Python (gevent probably being its most used flavor).

i.e.: just because it's not in the standard library doesn't mean it's not available (so, you can actually choose whether you'd like to use async/await or greenlets).

fabioz··on Tell HN: Turned 44 today and I'm lost
My 2c: not all therapies are the same...

I recommend you start with a professional that works with `Cognitive Therapy` (from what I've heard it's one of the more recent therapies and its practices are based on evidences -- that's not the case for all therapies out there).

fabioz··on Python 3.10
Well, I wouldn't say that it'll slowly die given that there are many workarounds one can use to use multiple processors for CPU-heavy workloads even when the GIL is present (such as releasing it in native extensions or using multiprocessing).

So, while it's discussed a lot, it seems like it did become one of the most popular languages even having a GIL -- but I guess we'll never know for sure as there are real plans to make a GILless CPython now...

fabioz··on Python 3.10
Yes, but Jython and IronPython (which were the only implementations that I know of that effectively didn't have a GIL) were much slower in general, didn't work with native extensions and were always lagging a lot on the supported version (so, yes, there's not much interest in having a GILless version with these shortcomings -- so, IMHO, CPython is right in only accepting a GIL removal if the performance in general doesn't suffer and which has a good path forward for compatibility of the existing native extensions ecosystem).
fabioz··on Pint – A Python package to define, operate and manipulate physical quantities
Internally the library has a "quantity type", which defines for a given quantity all the given conversions that are valid in the database and a "category" which is used so that you can create subsets of units which you want to consider valid for your application.

It's helpful in the context that you want to restrict what's valid for such a category (see: https://github.com/ESSS/barril/blob/master/src/barril/units/... for what that means -- think of defining a "cylinder width" as a subset of "length").

As a note, it's main use-case is NOT doing computations such as dividing/multiplying Scalars (albeit that's supported it does have some caveats -- so, while it also does dimensional analysis, it's really not the core functionality), rather the core functionality is making the conversions based on what's available in the unit database (so, you're not supposed to be creating units out of the unit database, rather, you want to collect input from the units you support and then make your conversions to other units you still support -- think of doing validation of input, converting to values in units expected by the user, defining a unit-system for input, converting to your internal unit-system for actual computation in C/C++, ...).

So, I guess it depends on what you consider as core for a units library. As I mentioned, it's created for an Oil & Gas use-case -- albeit it's also used in other engineering-related projects -- where the units are all pretty much well mapped in the application and you're worried that you are getting into units you're not expecting and that'd actually be an error.

p.s.: if you have specific use-cases which don't work as you expect, I suggest contacting the library maintainers -- once that was me, but it's been a while ;)

p.s.: thanks for letting me know about how to deal with dimensionless units in pint (I wasn't aware of that).

fabioz··on Pint – A Python package to define, operate and manipulate physical quantities
I'd like to point to a separate library for dealing with units: Barril

https://github.com/ESSS/barril

Docs at: https://barril.readthedocs.io/en/latest/

While it does have support for creating "random" units from computation (such as Pint, unum, etc), it's more tailored to having a database of units (which the library has by default -- see: https://barril.readthedocs.io/en/latest/units.html and the implementation: https://github.com/ESSS/barril/blob/master/src/barril/units/...) and then you can query and transform based on the related units.

One thing it supports that does a lot of difference in that regard is dealing with unit conversions which would be "dimentionless" -- such as m3/m3 (i.e.:`volume per volume`) and then converting to `cm3/m3` and keeping the dimension.

i.e.: in pint:

  >>> import pint
  >>> ureg = pint.UnitRegistry()
  >>> m = ureg.meter
  >>> v = 1 \* (m\*3)/(m\*3)
  >>> v
  <Quantity(1.0, 'dimensionless')>
And then, after that (as far as I know), it's not really possible to do additional unit conversions properly knowing that it was m3/m3.

In barril:

  >>> from barril.units import Scalar
  >>> a = Scalar(3, 'm3/m3')
  >>> a.GetValue('cm3/m3')
  3000000.0
  >>> a.category
  'volume per volume'
  >>> a.unit
  'm3/m3'
and something as `a.GetValue('m3')` (with an invalid value) would give an error saying that the conversion is actually invalid.

The unit database (which was initially based on the POSC Units of Measure Dictionary) is a bit more tailored for the Oil & Gas field, but should be usable outside of it too.

fabioz··on Firefox Release 89.0
I'm a long time user of FF.

I really don't like the UI changes in this upgrade, but setting:

"browser.proton.enabled" to false

"browser.uidensity" to 1

(while using the `System Theme`)

Seems to have done the trick, so, I can just ignore the UI changes (which is great)... fingers crossed in that this keeps working in the future.

UI changes are very much subjective, so, I think that it's great that some people like the new UI better and keep using it as long as there's also a way to not alienate existing users that like the existing UI.

fabioz··on PEP 563, PEP 649 and the future of pydantic and FastAPI
I must say I've just spent quite some time looking at both PEPs and discussions and I'm strongly in favor of PEP 563 right now... it does improve the performance of typed modules substantially (which is a big downside for me in typed codebases) -- PEP 649 improves the situation but still adds a considerable overhead to the import time.

I think that the numbers given from Inada Naoki https://mail.python.org/archives/list/python-dev@python.org/... do sum it well.

Also, I don't see what will be made impossible at the pydantic side... from the bug list that's shown at https://github.com/samuelcolvin/pydantic/issues/2678, yes, the code needs to be adapted, but I don't see what's made impossible (maybe at some point the pydantic devs will actually say what the real problems are as so far no real concrete info on that was given).

Heck, they could even probably not even use `typing.get_type_hints()` (which currently apparently does an internal `eval()` and treat the annotation string however they'd like -- maybe more work, but then, absolute freedom to treat it as they see fit).

So, my plead goes the other way around: please don't make all projects which don't require runtime info from annotations pay the price for the few use cases which do use them (but don't make those impossible either -- but my take so far as that this is not the case).

fabioz··on PEP 563, PEP 649 and the future of pydantic and FastAPI
Well, this particular change (PEP 563) is IMHO actually striving for improved static typing and better performance, so, I guess they're in sync with that.

-- PEP 649 would undo those performance improvements and possibilities of improved static typing over concerns of libraries that user types at runtime having to adapt (I took a look at the issues reported at pydantic and while the API would need to be adapted when PEP 563 would come into effect, I don't really see the major breakage they're talking about -- not that it doesn't take some work to adapt, but I don't see the reason it'd suddenly become impossible to do, it'd only make their own lives a bit easier over the performance cost of all the libraries that use typing without requiring runtime information).

fabioz··on Reloadr – Hot code reloading tool for Python
Ha, I'm just working on integrating the `pydev.debugger` code reloading into `debugpy` (so that the code reloading from the PyDev debugger will be available for Python-VSCode debugger users too).

The in-memory reloading (which may be seen at: https://github.com/fabioz/PyDev.Debugger/blob/main/_pydevd_b...) unfortunately doesn't work all the time (fixing the references at runtime in Python is difficult), but it works well enough for the cases where you have a simple function and change it (that file does explain some of the issues that the reloading faces).

One major issue is that after doing the reload, you need to get out of the function and then back into it to see the difference -- so, if you're stopped in the function in a breakpoint, it's not possible to simply drop the function and restart it as Python itself doesn't support that... maybe that's a good idea for a PEP ;)

Anyways, when it works, it's pretty nice in that you don't have to restart your whole debug session to see changes (the other approach, which webservers use in general is just restart the whole process, so, for instance, Django has an initial process just monitoring for changes and a 2nd process which is actually serving requests which is restarted when something changes -- not as good if you have a heavy startup or are working with something where you have to click through multiple things to get to the state which you want).

fabioz··on Hypermodern Python
I personally enjoy using https://github.com/google/python-fire nowadays.

-- it's probably not the most flexible tool, but IMHO it's the one with the best API: fire.Fire(obj) and everything else is taken care of ;)

p.s.: for lazy imports, just don't put them in the top of your module in the entry point.

fabioz··on Hypermodern Python
The real problem (which is solved by conda) is that pypi doesn't solve dealing with non-python packages well (say, compile scipy and make all related native packages communicate well). This is a huge issue for people dealing with scientific packages (and the main pain point which pypi being just python-focused on installing on site-packages doesn't solve well enough IMHO).

Also, while it was initially done by a private company, I'd say it's definitely a community effort right now (it's also the reason I tend to use https://conda-forge.org/, which is community driven and not anaconda).

As for dealing with pypi, it does integrate well enough for me (given that you can just pip install packages on the python for which conda is managing the env), but yes, the other way around isn't true (conda solves a bigger problem than pypi up to the point that it's possible to even have non-python tools available -- one real use case example I have here is having innosetup binaries as a tool in the PATH in some conda env for doing builds).

Note: I don't have any affiliation with any of that, these are just my preferences for managing python envs (when I'm developing pydevd, which is the debugger engine used in pydev/pycharm/vscode, many times I need to reproduce some weird env and before using conda that was pretty annoying).

fabioz··on Hypermodern Python
I guess that there are many tools for environments now... my personal choice is using conda (I actually start with miniconda and download what I need from conda-forge).

It provides the needed isolation, you can get lots of packages without having to compile from conda-forge and it still works with pip for the odd cases where a given package is not directly available (as a bonus, it works for other native toolchains, not only Python, which is a huge plus for me).

As a note, I personally use it with `conda devenv` to be able to replicate installs for a given project -- i.e.: https://conda-devenv.readthedocs.io/en/latest/.

fabioz··on What Does a Coder Do If They Can't Type?
My experience is different here... changing to Dvorak + changing mouse to a trackball in the left hand (along with a MS ergonomic keyboard) made a world of difference for me.

I can currently code a whole day without feeling anything... coming from not having enough strenght to hold a glass sometimes due to RSI -- 10 years since I did the switch already... having to type much slower when doing the switch to Dvorak also forces you to be slower and helps in the initial recovery.

As a note for people with issues, don't go to pain killers when you're still typing, you'll only make the problem worse... if you go to pain killers make sure you also stop typing/injuring yourself.

fabioz··on Python is becoming the world’s most popular programming language
Personally, I think that refactoring Python is straightforward (and many refactorings you need to do are much simpler and easier to do without breaking existing APIs -- doing refactorings in Java usually needs changing much more code even for simple things).

I think that the real problem is not having a good test coverage, and I agree that bad programs written in Python may be harder to work with than bad programs written in a statically typed language (but in a good codebase, even if large, I'd rather be working with Python).

-- although note that in the latest incarnation of Python you can try to use Mypy (http://mypy-lang.org/) along with https://github.com/Instagram/MonkeyType or https://github.com/dropbox/pyannotate to add types to you and go from there if you really miss types too much and this could make a bad codebase bearable (I'm personally waiting for PEP 544 before adding any types though as I'm not a fan of the type system implemented in PEP 484 very much).

fabioz··on How we rolled out one of the largest Python 3 migrations
Cython is a pretty good Python to C compiler and in its latest release is using type annotations... the thing is, you shouldn't need to compile your whole program (compiling is really slow and interpreted Python is fast enough for most of the code).
fabioz··on PyQt5 Tutorial: Create a Python GUI in 2018
Yeap, it's pretty easy (see: https://github.com/rocky/python-uncompyle6), although note that if you're worried about decompiling, instead of using an obfuscator, using something as Cython or Nuitka to compile your code should not be difficult -- and as a plus your code becomes faster too ;)
fabioz··on Diminishing returns of static typing
I find that people doing these claims have seldomly really worked in large Python codebases...

Personally, I find it pretty workable in Python with a big codebase (but you have to respect the rules like having a good test suite -- you change the time from compiling to running your test suite -- which you should have anyways)...

I find that the current Python codebase I'm working on (which has 15 years and around 15k modules -- started back in Python 2.4, currently in Python 2.7 and going to 3.5) pretty good to work in -- there's a whole class of refactoring that you do on typed languages to satisfy the compiler that you don't even need to care about in the Python world (I also work on a reasonably big Java source codebase and refactorings are needed much more because of that).

I must say I'm usually happier on the Python realm, although, we do use some patterns for types such as the adapter protocol quite a bit (so, you ask for a type and expect to get it regardless of needing a compiler to tell you it's correct and I remember very few cases of errors related to having a wrong type -- I definitely had much more null pointer exceptions on java than typing errors on Python) and we do have some utilities to specify an interface and check that another class implements all the needed methods (so, you can do light type checking on Python without a full static checking language and I don't really miss a compiler for doing that type checking...).

I do think about things such immutability, etc, but feel like the 'we're all responsible grown ups' stance of Python easier to work with... i.e.: if I prefix something with '_' you should not access it, the compiler doesn't have to scream that it's private and I don't need to clutter my code -- you do need good/responsible developers though (I see that as an advantage).

fabioz··on Visual profiler for Python
http://www.pyvmmonitor.com also provides a nice visual profiler.
← PreviousPage 2 of 2