Live data from Hacker News

Django 3

docs.djangoproject.com

71–80 of 196 posts

Re: Django 3

#71
post #67

If you can convince your company to keep Django up-to-date with every release, I have found this to be easy and pain-free (Django has been pretty API stable since ~1.8), compared with waiting for each LTS and then being forced to jump ahead three versions each time. You also gain access to new features as they come out, this way.

But you have to be careful that all dependencies are up-to-date as well.

No to mention each new release have many incompatibility that you need to read the release note to find out

Re: Django 3

#72
post #38

I have been using FastAPI for the last two months (which also is an ASGI server and makes full use of annotations and type hints with mypy) and the experience has been incredible. ( https://fastapi.tiangolo.com/ ) If Django can now also support annotations and async code I dream of an scenario where apis can be built using this two elements. Does anybody know a good resource to learn/catch up with this release?

Pyotr [0] is a small library I've been developing for a while, based on Starlette. In a nutshell, it takes an OpenAPI specification and turns it into an API application, taking care of all the routing and validation according to the spec. It is conceptually similar to connexion [1], but it supports async and is Python 3 only. There is also a client component, in the spirit of bravado [2].

[0] https://pyotr.readthedocs.io

[1] https://connexion.readthedocs.io/

[2] https://github.com/Yelp/bravado

Re: Django 3

#73
post #68
post #48

Earlier quoted context omitted.

Your experience is very much unlike my own. Every project I’ve seen hit issues with the database (e.g. unindexed queries, changing data access patterns) first, followed by I/O (especially other services like S3, search, etc.), and RAM usage before CPU became a major factor. It’s possible, of course, but I’ve usually seen it as a symptom of not having a good culture around monitoring and troubleshooting — e.g. I remem…

Of course, if you are incompetent enough to write queries that use no indexes and you don't detect that before you push to prod, you will have problems there. What I mean is: when you start optimising, no matter how well you do, you will eventually hit a CPU performance wall. Then you will realise that only a rewrite will get you out of that hole, and by then it will be late.

In my experience, many sites never hit that point of having CPU-bound Python code which they can’t afford; the ones which do hit that wall are usually large enough that they can carve out room for a C/Rust library, microservice, etc. rather than rewriting the entire thing.

Re: Django 3

#74
post #38

I have been using FastAPI for the last two months (which also is an ASGI server and makes full use of annotations and type hints with mypy) and the experience has been incredible. ( https://fastapi.tiangolo.com/ ) If Django can now also support annotations and async code I dream of an scenario where apis can be built using this two elements. Does anybody know a good resource to learn/catch up with this release?

It's worth pointing out that the ASGI support in this release is very low level, and doesn't let you write async views or anything yet. We're still working on that.

Re: Django 3

#75

Groovy. I am excited to try out the new ASGI goodness. Last time I used Django Channels it was a constant struggle to tune it, prevent it from becoming deadlocked, etc. And the transition from Channels 1.x to 2.x was also not pleasant. I hope that Django proper did things better/differently.

Well there's no actual async support for views in 3.0 - we missed the cutoff due to performance concerns! Hopefully it'll be in 3.1.

Re: Django 3

#76
post #24

Earlier quoted context omitted.

I mean, what kind of performance issues were you running into? You're not going to get maximum performance out of a python program, generally. But unless your python program is using 100% cpu that's not really an issue, and there are very few cases where I'm using python and it's CPU that's slowing down the program. Mostly it ends up being some kind of IO. If you're looking to do complicated mathematical operations,…

In my experience most people creating CRUD websites with Django will hit a CPU bottleneck.

In my experience it doesn't sound like you have a lot of experience anywhere near CRUD websites with Django or otherwise.

Re: Django 3

#77

Groovy. I am excited to try out the new ASGI goodness. Last time I used Django Channels it was a constant struggle to tune it, prevent it from becoming deadlocked, etc. And the transition from Channels 1.x to 2.x was also not pleasant. I hope that Django proper did things better/differently.

Well there's no actual async support for views in 3.0 - we missed the cutoff due to performance concerns! Hopefully it'll be in 3.1.

Thanks for the info & for your work!

Re: Django 3

#78

This looks neat. Does anyone have experience with using type hints and mypy with Django? Any gotchas?

Django (and DRF if you use it), uses too much reflection, which doesn't play nice with type annotations. The strategy that works for me is to annotate my application code, and keep using dynamic typing when interacting with the framework.

Re: Django 3

#79
post #18
post #5

Does Python still have performance issues? That's always been my concern when considering its adoption.

Yes. If you can afford the CPU power, by all means go with Python. Otherwise just don't. Instagram can afford it so it works fine for them. Reddit can't, so their site is always slow or down.

You don't know what you're talking about.

Re: Django 3

#80
post #26

Right as I was just about to start a new Django project... The thought going through my mind right now is "I wonder if there is some way of creating a Django project and make it resilient to future Django updates and releases with minimum fuss?" I've had to deal with ongoing and inherited legacy projects which run on Python 2.7, use the long-deprecated Pylons, for which there is no easy upgrade path other than a tota…

I work as a contractor and have codebases in python, f#, delphi, swift, obj-c and now rust. > "I wonder if there is some way of creating a ???? project and make it resilient to future??? updates and releases with minimum fuss?" - Use control version (mercurial, git, ...) in everything, including utils and side projects. - Record all dependencies somewhere in the project. - Automate the builds, so you also have how re…

Very interesting. I myself was dealing with a Java project I need to maintain for legacy reasons on MySql 5.1. I Just spoon up a Django project aside, and used Peewee[0] to access without changes the DB. Works like a charm and easily integrated in Django midleware.

[0]: https://github.com/coleifer/peewee/issues/1995

Post reply on HN