Closed claird-ot closed 2 years ago
Are you asking for importing only one specific object instead of importing everything? Then you can do the following
from aws_lambda_typing.events.sqs import SQSEvent
from aws_lambda_typing.context import Context as context_
I appreciate you asking, MousaZeidBaker. Yes, I am fond of more precise import
-ing, and practice it in my own coding; it's indeed pertinent in this conversation.
My team has a more general concern, though. Lambda-s, in our understanding, are minimal: they do the least work possible, are active as little as possible, and, in particular, put a premium on rapid coldstart time. Our current thinking is that we can only afford to import aws_lambda_typing
or even from aws_lambda_typing import ...
only within if TYPE_CHECKING:
, because lambda-s simply can't afford the run-time cost of finding and then reading aws_lambda_typing
. Has no one else raised this point?
We do not yet have satisfying ways to measure the impact of import aws_lambda_typing
within a lambda. We're operating more at a folklore level, at this point.
aws_lambda_typing
is extremely lightweight with zero dependencies (python >3.7) so I wouldn't be worried. Plus everything outside the handler method such as importing packages is only executed on cold starts.
Thanks, MousaZeidBaker: just the kind of detail I appreciate. While I recognize that the source is right there for inspection, and all of us can confirm those facts about light-weight actions, it might be worth summarizing them in the README.md
just as you have for me: "... extremely lightweight ... only executed on cold starts." You advertise that aws_lambda_typing
is "convenient"; I also needed reassurance about its safety or performance.
I'm closing this Issue
now; you've answered my questions, with one exception: do you want a pull request from me, one focused exclusively on the README.md
as I imagine it might be?
aws_lambda_typing
surprises me, in that I'm accustomed to an emphasis in lambda coding on the lightest, fastest computations possible. As fond as I am of typing rigor, how can my lambda definitions afford toimport aws_lambda_typing
, rather than just crudely and "locally" approximating anSQSEvent
as adict
, and aContext
as anobject
?