[英]Is there an advantage to Lambda Powertools’s Parser over straight Pydantic?
I've got models which inherit Pydantic's BaseModel and I use this to define my model attributes and do some validation.我有继承 Pydantic 的 BaseModel 的模型,我用它来定义我的 model 属性并进行一些验证。
But I see that Lambda Powertools comes with a Parser module which uses Pydantic.但我看到Lambda Powertools 带有一个使用 Pydantic 的解析器模块。
Now that I want to use these models within an AWS lambda execution, is there a benefit to using:现在我想在 AWS lambda 执行中使用这些模型,使用以下方法有好处吗:
from aws_lambda_powertools.utilities.parser import BaseModel
Instead of sticking with my existing而不是坚持我现有的
from pydantic import BaseModel
I can see that the Powertools Parser comes with a useful BaseEnvelope - but is BaseModel in Powertools any different?我可以看到 Powertools Parser 带有一个有用的 BaseEnvelope - 但是 Powertools 中的 BaseModel 有什么不同吗?
And as a followup, if there is a benefit, could I monkey patch within the lambda runtime so I can:作为后续,如果有好处,我可以在 lambda 运行时内打补丁,这样我就可以:
You don't have to update your imports.您不必更新导入。 AWS Lambda Powertools's BaseModel is just a re-export of Pydantic's BaseModel .
AWS Lambda Powertools 的 BaseModel 只是 Pydantic 的 BaseModel 的再导出。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.