Skip to content

Commit

Permalink
Remove assertions.
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonspeed committed Mar 27, 2024
1 parent c709d3f commit 6bbec54
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
5 changes: 0 additions & 5 deletions src/twisted/internet/defer.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,6 @@ def addCallbacks(
if errbackKeywords is None:
errbackKeywords = {} # type: ignore[unreachable]

assert callable(callback)
assert callable(errback)

self.callbacks.append(
(
(callback, callbackArgs, callbackKeywords),
Expand Down Expand Up @@ -873,7 +870,6 @@ def callback(self, result: Union[_SelfResultT, Failure]) -> None:
@raise AlreadyCalledError: If L{callback} or L{errback} has already been
called on this L{Deferred}.
"""
assert not isinstance(result, Deferred)
self._startRunCallbacks(result)

def errback(self, fail: Optional[Union[Failure, BaseException]] = None) -> None:
Expand Down Expand Up @@ -1552,7 +1548,6 @@ def _cbDeferred(
if succeeded == SUCCESS and self.fireOnOneCallback:
self.callback((result, index)) # type: ignore[arg-type]
elif succeeded == FAILURE and self.fireOnOneErrback:
assert isinstance(result, Failure)
self.errback(Failure(FirstError(result, index)))
elif self.finishedCount == len(self.resultList):
# At this point, None values in self.resultList have been
Expand Down
1 change: 1 addition & 0 deletions src/twisted/newsfragments/12122.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``twisted.internet.defer.Deferred`` operations use less CPU.

0 comments on commit 6bbec54

Please sign in to comment.