Commit a19f275
committed
Suggestion: don't import uvicorn to allow for alternative asgi servers
The `core.py` file imports uvicorn even though it's only used for
`serve()` calls.
I'm deploying a FastHTML app to AWS Lambda, and extra imports cause
longer cold starts. I did a naive test (3 samples of each) and it seems
like this uvicorn import takes 10-25ms to load.
Moving the `uvicorn` import into `serve()` still works, and doesn't seem
to violate the project style guide.1 parent 11dc14b commit a19f275
2 files changed
+4
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
638 | 638 | | |
639 | 639 | | |
640 | 640 | | |
| 641 | + | |
641 | 642 | | |
642 | 643 | | |
643 | 644 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
1582 | 1582 | | |
1583 | 1583 | | |
1584 | 1584 | | |
| 1585 | + | |
1585 | 1586 | | |
1586 | 1587 | | |
1587 | 1588 | | |
| |||
0 commit comments