Why does pycharm propose to change method to static

前端 未结 9 1591
面向向阳花
面向向阳花 2020-12-22 18:41

The new pycharm release (3.1.3 community edition) proposes to convert the methods that don\'t work with the current object\'s state to static.

9条回答
  •  抹茶落季
    2020-12-22 18:51

    I can imagine following advantages of having a class method defined as static one:

    • you can call the method just using class name, no need to instantiate it.

    remaining advantages are probably marginal if present at all:

    • might run a bit faster
    • save a bit of memory

提交回复
热议问题