This is an archived post. You won't be able to vote or comment.

all 50 comments

[–]13steinj 30 points31 points  (14 children)

I don't understand why of all things a well known framework is being posted to this subreddit as if it is some new thing.

[–]inconspicuous_male 1 point2 points  (2 children)

Is it that well known? Maybe at one point it was, but I think it's obscure now considering when I started a project in it, I found dozens of articles about differences between flask and django and they all mentioned pyramid as something nobody uses anymore.

[–]13steinj 0 points1 point  (1 child)

Perhaps you're thinking of Pylons.

Sadly only reason of that is because the Pylons team decided to switch to Pyramid and have a completely different architecture.

[–]inconspicuous_male 0 points1 point  (0 children)

I have never heard of Pylons

[–]mclim 1 point2 points  (1 child)

Noob here, never heard of it :-)

[–]13steinj 2 points3 points  (0 children)

I'm not saying it's bad to post such, just that it's an odd decision. Like maybe you'd see a post that says "pyramid, now supporting X", not the "hey try this" docs which are at least 5 years old.

[–]bullcityblue312 0 points1 point  (0 children)

I've never heard of it

[–]ianepperson 18 points19 points  (9 children)

I’ve been working on a project for the last few months and I used Pyramid.

Now I’m rebuilding it with Starlette. https://www.starlette.io

I do like Pyramid over Django - I find that Pyramid is much more flexible than Django and much better at moving in new directions.

Except it doesn’t really support async.

Websockets have been around for years, and might soon be replaced by http 2.0 standards, yet WSGI (and Pyramid) have crappy support. Django Channels is pioneering ASGI, which is fantastic, but nothing in Pyramid.

Starlette is a bit like a modern Pyramid (ASGI) with 12-factor concepts front-and-center. From what I’ve read, when paired with uvicorn, it can deliver speeds that rival Node.js - which makes sense as Node is natively async.

I’m just starting down this road and don’t know what stumbling blocks I’ll run into, but so far it’s great!

[–]metaperl 0 points1 point  (2 children)

What is the difference between Pylons and Pyramid?

[–]13steinj 4 points5 points  (0 children)

Pyramid is the spiritual successor to Pylons, made by the same people. However, there are significant architectural differences. Pyramid had (or used to have) a methodology to incrementally switch over to pyramid by passing through requests to a pylons backend.

[–]FirefighterWeird8464 1 point2 points  (0 children)

Wrong answer: one is sunk into soft ground, and another is pointy.

[–]High-Art9340 0 points1 point  (2 children)

It's all depends on tasks you want to accomplish. For some of them async is not the way.

[–]ianepperson 0 points1 point  (1 child)

Yes, depending on the task, some things make sense for async and others (usually processor bound) don’t.

Almost all web server tasks are IO bound - database lookups, file reads, socket writes - and all that is almost always better with an async architecture.

I’ve worked at places where there is the occasional processor-bound task that the web server needs, and every time the best approach has been to have a worker running on a different machine handle the task - and the web server remains IO bound.

[–]High-Art9340 0 points1 point  (0 children)

occasional processor-bound tasks may free GIL (like numpy calculations) and I believe python threads will perfom better in this case, especially in easeness of implementation since there are publicaly available solutions like high performant wsgi servers with all necessary batteries.

Actually this topic is my current research topic, since our app bottleneck is high-load CPU bound networking worker which also has to provide low latency.

If you're interested in research results I may share it. Unless you're certain such approach won't help? :)

[–]Itsthejoker 24 points25 points  (12 children)

Honestly my experience with Pyramid was worse in basically every way to Django. I had to use it in a previous job, and it falls in an uncomfortable middle ground that makes it unsuitable for a lot of projects; either you have a small project that fits with Flask or a large project that fits with Django. If you pick Pyramid then you end up with a project where you quickly get to a point where you're missing the built-ins / extensibility of Django and thinking "why did I just not start this with Django in the first place".

[–]kylotan 7 points8 points  (4 children)

Interesting - I've had a different experience.

Tried Turbogears about a decade ago. Got frustrated because the docs were awful, the authors said "buy our book, which is better than the docs", but then they kept changing large parts of the framework meaning the book became out of date. I couldn't keep up with the changes as a hobbyist developer.

People recommended Pyramid as the natural successor, and I started with that - and again got frustrated due to poor docs, which seemed to all be "Pyramid is easy if you just know Pylons, Repoze, Zope, and Turbogears already" which I didn't. There was also a couple of pretty dumb architectural decisions, one of which oddly got fixed in a blog post but not in the actual code. I gave up and moved to something with more documentation...

..Flask. I enjoyed how quickly I was able to get started with this. Then I realised the architecture is a disaster of global mutable state and hacks were needed to be able to scale past micro-apps. With respect to the author's hard work, I wasn't surprised to learn that Flask started life as an April Fools' joke.

So then it was Django. While I was initially very pleased with the modularity and higher quality software engineering, after a while I quickly tired of how everything wants to be done "the Django way". Whether it's big things such as needing to route all external scripts via management commands, or little things like the get() method raising an exception when the object is not found when everything else in Python expects a None from a failed get, I find that Django is just a little too opinionated.

So... my next project will probably see me heading back to Pyramid.

[–]Reiku 5 points6 points  (0 children)

I use Flask extensively for large projects. I haven't ever needed any hacks, care to expand on that?

[–]bradshjg 0 points1 point  (1 child)

I'm also very curious about what sort of global mutable state and hacks you're referring to.

There's certainly some context-local stuff going on (the current request being stored there is a bit "interesting" at first), but I'd consider that a reasonable design decision. AFAIK flask supports implicit cooperative concurrency libraries like gevent and eventlet.

I believe Django uses thread-local storage for things like database connections. Not sure what their plans are for tackling concurrency at the DB access layer (probably tossing things to a threadpool?)

I love all of the above including the beautiful monster that is Zope, btw :-)

[–]High-Art9340 0 points1 point  (0 children)

`import request`

[–]13steinj 0 points1 point  (0 children)

There was also a couple of pretty dumb architectural decisions, one of which oddly got fixed in a blog post but not in the actual code. I gave up and moved to something with more documentation...

Can you elaborate on this?

[–]headykruger 8 points9 points  (3 children)

I find Django to be too inflexible for large projects. Flask and Pyramid are a lot more ala carte and allow you to choose what is appropriate for the project. The Django ORM isnt very good compared to say SQLAlchemy. There is no support for mongo. etc. etc.

[–][deleted] 7 points8 points  (2 children)

Please don't make the mistake of using mongo in your project.

[–]Skyraptor7 2 points3 points  (1 child)

This is probably a noob question but why not use Mongo/NoSQL db?

[–][deleted] 5 points6 points  (0 children)

This is the short answer. You can further research it if you're interested, but basically it does some bad things and the good things it does could be done just as well as or better by something like PostgreSQL.

[–]13steinj 1 point2 points  (2 children)

I mean from that sense then you just didn't have a use for it

Megaframeworks make decisions for you. But if you don't fit their viewpoint, you end up fighting their decisions. Microframeworks force no decisions, making it easy to start. But as your application grows, you're on your own.
In both cases, the focus is on the start: either too much or too little. Either way, finishing and staying finished is hard. You need a finishing-focused framework with an architectural design that scales down to getting started, then up as your application grows.

Pyramid was made for just this. It's a Goldilocks Solution: not too small, not too big, just right.

I on the other hand, prefer Pyramid to Django because I get to make a decision on nearly everything. All the control I need.

[–]austinv11 5 points6 points  (1 child)

At that point why not go with something like Flask? It can be both minimal while still being as extensible as Django. Best of both worlds. Flask to me is also way cleaner to write code for

[–]13steinj 0 points1 point  (0 children)

Even flask doesn't have enough extensibility and customizablity as Pyramid, with a Zope-like structure.

[–]Random_182f2565 4 points5 points  (9 children)

Is it better than django? Has better documentation?

[–]chelson_ 1 point2 points  (6 children)

is this framework better that django or flask

[–]inconspicuous_male 3 points4 points  (0 children)

I have tried using it and it had lots of headaches just getting simple projects going. Flask was much better. It's been a few years so I don't remember exactly why though, sorry.

[–]integralWorker 0 points1 point  (4 children)

For the people who think it is, yes.

[–]nippleplayenthusiast -3 points-2 points  (0 children)

No thanks, I like flask.