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

Fix function's arg default List #12

Closed
wants to merge 1 commit into from

Conversation

wunder957
Copy link
Contributor

Mutable object such as Dict and List should never be default value

Default values are computed once, then re-used.

Default parameter values are evaluated when the function definition is executed. This means that the expression is evaluated once, when the function is defined, and that the same “pre-computed” value is used for each call.

>>> def demo_list(l=[]):
...   l.append("data")
...   return l
...
>>> print(demo_list())
['data']
>>> print(demo_list())
['data', 'data']

This can lead to unexpected issues.

@wunder957 wunder957 added the bug Something isn't working label Aug 18, 2023
MooooCat
MooooCat previously approved these changes Aug 21, 2023
Copy link
Contributor

@MooooCat MooooCat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@MooooCat MooooCat changed the base branch from main to dev August 21, 2023 10:42
@MooooCat MooooCat changed the base branch from dev to main August 21, 2023 10:43
@MooooCat MooooCat dismissed their stale review August 21, 2023 10:46

model的2哥基类目前已合并 ,这个函数的修改是对的,后续添加到至 sdgx/models/base.py 应该更合适

@MooooCat
Copy link
Contributor

MooooCat commented Aug 21, 2023

感谢感谢,目前model的2个基类目前已合并 ,这个函数的修改是对的,后续添加到至 sdgx/models/base.py 中的 BaseSynthesizerModel 应该更合适。

另外我们最新的更新还在 dev分支,尚未合并到 main 分支。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants