英文:
Is there an advantage to Lambda Powertools’s Parser over straight Pydantic?
问题
我有继承Pydantic的BaseModel的模型,并使用它来定义我的模型属性并进行一些验证。
但我看到Lambda Powertools带有一个Parser模块,它使用了Pydantic。
现在,我想在AWS Lambda执行中使用这些模型,是否有以下好处:
from aws_lambda_powertools.utilities.parser import BaseModel
而不是继续使用我的现有:
from pydantic import BaseModel
我可以看到Powertools Parser带有一个有用的BaseEnvelope - 但Powertools中的BaseModel是否有任何不同?
作为后续问题,如果有好处,我是否可以在Lambda运行时进行monkey patch,以便我可以:
- 使我的模型独立于任何与Lambda相关的内容。
- 节省自己更改所有导入的工作。
英文:
I’ve got models which inherit Pydantic’s BaseModel and I use this to define my model attributes and do some validation.
But I see that Lambda Powertools comes with a Parser module which uses Pydantic.
Now that I want to use these models within an AWS lambda execution, is there a benefit to using:
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?
And as a followup, if there is a benefit, could I monkey patch within the lambda runtime so I can:
- Keep my models independent of anything Lambda like.
- Spare myself from changing all the imports.
答案1
得分: 1
你不需要更新你的导入。AWS Lambda Powertools的BaseModel只是对Pydantic的BaseModel的重新导出。
英文:
You don't have to update your imports. AWS Lambda Powertools's BaseModel is just a re-export of Pydantic's BaseModel.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论