len(seq) - 1
to get last element of an iterable PTC-W0044There’s no need to calculate length of an iterable in order to fetch the last element of the iterable. You can provide a negative index -1
to it directly in orger to get the last element. In this way, you don't have to iterate over the sequence using len
to get the last index when your purpose is only to get the last element.
@staticmethod
PYL-R0201The method doesn't use its bound instance. Decorate this method with @staticmethod
decorator, so that Python does not have to instantiate a bound method for every instance of this class thereby saving memory and computation. Read more about staticmethods here.
The preferred way is to add a new DB column with null=True
because it will be created instantly and then possibly populate the table with the desired default values. Adding a default value will lead to a performance issue if the existing table has a large number of rows.
An expression that is not a function call is assigned to nothing. Probably something else was intended here. We recommend to review this.
Using the literal syntax can give minor performance bumps compared to using function calls to create dict
, list
and tuple
.