Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consider using Routes for routing #1318

Closed
petri opened this issue Sep 16, 2018 · 18 comments
Closed

consider using Routes for routing #1318

petri opened this issue Sep 16, 2018 · 18 comments

Comments

@petri
Copy link

petri commented Sep 16, 2018

Routes https://routes.readthedocs.io/en/latest/ is a mature router implementation that focuses on URL routing and nothing more.

@ahopkins
Copy link
Member

Do you have any benchmarks? What benefits would you see for adopting this over the existing solution? I'm personally in favor of keeping external dependencies as slim as possible. While the sanic router could use some work, and is generally rather performant, I would not be in favor of adding a third party package. I know of a few other alternative ideas floating around.

@vltr
Copy link
Member

vltr commented Sep 16, 2018

@petri @ahopkins tomorrow I'll probably have a good benchmark suite over some known (and lesser known) URL routers for Python 😉

@vltr
Copy link
Member

vltr commented Sep 17, 2018

@petri I wrote a small benchmark suite for testing different routing systems in Python. Here's the repository. I don't believe Routes is a good choice and, if a mature routing system is to be considered, then I would really consider Falcon's.

@ahopkins
Copy link
Member

ahopkins commented Sep 17, 2018

@vltr nice work! Thanks for sharing.

@sjsadowski
Copy link
Contributor

I agree with @vltr but I will claim bias as I migrated to Sanic from Falcon.

@vltr
Copy link
Member

vltr commented Sep 19, 2018

@sjsadowski yeah, well, I'm glad this benchmark is just for the router 😄

Being "pure Python", the Falcon router really does a good job (Sanic does too, but with a lot of regex and high complexity searches, yet still error prone in some situations).

@ahopkins
Copy link
Member

Since we are on the topic ...

I'm curious to hear how people would react to using C extensions or cython in situations like this one to gain some more performance.

@vltr
Copy link
Member

vltr commented Sep 19, 2018

@ahopkins not only performance may I add; the Sanic router, like I said, might be error prone in some situations exactly because of its complexity (and flexibility). I know very well that it was (made this way) with the best of intentions, but this might be a trade-off between having such flexibility on the router or have a fast and reliable router ... It's hard to choose 😅

@sjsadowski
Copy link
Contributor

I tend to prefer flexibility over speed here (blasphemy?) because aside from everything else, we're still functioning at web-speed. I think also moving to an extension - that would be compiled - starts to increase difficulty of adoption for people who may not have access or support to build extensions.

@vltr
Copy link
Member

vltr commented Sep 25, 2018

No blasphemy at all. I believe that a compiled extension is on the table because we already depend on some (httptools, multidict). The point is the cost of having such flexibility on the router to be error prone and overly complex to maintain.

@ahopkins
Copy link
Member

I was not proposing compilation for users of Sanic, but before the release (hence whoever it is that is going to work on the development of the router). We can pre-compile and just import as if it were written in Python.

@c-goosen
Copy link
Contributor

I agree with @vltr but I will claim bias as I migrated to Sanic from Falcon.

Not alone in that quest!

@skewty
Copy link

skewty commented Nov 12, 2018

@ahopkins uvloop and ujson are already compiled dependencies. The decision was already made to favor speed. I say go for it.

@sjsadowski
Copy link
Contributor

@ahopkins @vltr do we want to keep this open?

@vltr
Copy link
Member

vltr commented Feb 8, 2019

@sjsadowski yes, I think it's good to leave it open and start a further discussion in the community forum since our current Router (and overall Request workflow (see #1317 and related issues)) really needs some attention - either from the performance perspective to the complexity perspective, design and etc.

@stale
Copy link

stale bot commented May 14, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is incorrect, please respond with an update. Thank you for your contributions.

@stale stale bot added the stale label May 14, 2019
@ahopkins ahopkins added necessary and removed stale labels May 15, 2019
@ahopkins
Copy link
Member

Related discussion here: https://community.sanicframework.org/t/making-sanic-even-faster/298?u=ahopkins

This is on my radar after ASGI.

@ahopkins
Copy link
Member

Closing this. The forums have plenty more information about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants