Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit48bf3a7

Browse files
committed
inspect: Fix isgenerator logic.
Also optimise both `isgenerator()` and `isgeneratorfunction()` so they usethe same lambda, and don't have to create it each time they are called.Fixes issue#997.Signed-off-by: Damien George <damien@micropython.org>
1 parent9307e21 commit48bf3a7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

‎python-stdlib/inspect/inspect.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
importsys
22

3+
_g=lambda: (yield)
4+
35

46
defgetmembers(obj,pred=None):
57
res= []
@@ -16,11 +18,11 @@ def isfunction(obj):
1618

1719

1820
defisgeneratorfunction(obj):
19-
returnisinstance(obj,type(lambda: (yield)))
21+
returnisinstance(obj,type(_g))
2022

2123

2224
defisgenerator(obj):
23-
returnisinstance(obj,type(lambda: (yield)()))
25+
returnisinstance(obj,type((_g)()))
2426

2527

2628
class_Class:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp