How modular is development?

Please excuse my naivety: How easy/common is it for developers of integrations, blueprints, sensors, scripts,… to integrate open source libraries / code modules that are provided by other developers?

As a simple example, many developers might feel the need for a moving average of a sensor value (e.g. temperature), but it’s not even so simple to write code that both works with sensors reporting every second and a high inaccuracy versus sensors that only report very rarely. Others might want to use a baesian logic, a state machine, an international holiday calender, a markdown-engine, a CVS parser, a validator for domains and email addresses, a language tokenizer, a neural net, a decision tree,… (just random examples)

All of that might already be available as open source library somwhere, performant and (hopefully) with less bugs that if you’d write it yourself.

I’m not familiar with Python at all. Yet. But I know the ecosystem of Ruby and there it’s common to include libraries (named “gems”) instead of reinventing the wheel. How does that compare to the Home Assistant ecosystem? Is there a folder in the file system containing all these libraries? Does each add-on have its own dependency management or do they share these libraries? And if I’d want to start developing something for HA, where’s the best place for this kind of ecosystem? Could I use anything written in Python as dependency that will be downloaded and installed automatically? Is there a way to see the top 100 used libraries in HA installations?

Thanks!