forked from Nuitka/Nuitka
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests: Added construct tests for generator expressions to check perfo…
…rmance.
- Loading branch information
Showing
4 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,9 @@ def generator(): | |
except exc: | ||
pass | ||
|
||
return throw, exc | ||
|
||
|
||
for x in xrange(50000): | ||
calledRepeatedly() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Copyright 2015, Kay Hayen, mailto:[email protected] | ||
# | ||
# Python test originally created or extracted from other peoples work. The | ||
# parts from me are licensed as below. It is at least Free Softwar where | ||
# it's copied from other people. In these cases, that will normally be | ||
# indicated. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
def calledRepeatedly(): | ||
# We measure making a generator iterator step or not. | ||
gen = (x for x in range(3)) | ||
|
||
next(gen) | ||
|
||
# Take attribute lookup out of it, and built-in lookup too. | ||
throw = gen.throw | ||
exc = GeneratorExit | ||
|
||
try: | ||
# construct_begin | ||
throw(exc) | ||
# construct_alternative | ||
pass | ||
# construct_end | ||
except exc: | ||
pass | ||
|
||
return throw, exc | ||
|
||
|
||
for x in xrange(50000): | ||
calledRepeatedly() | ||
|
||
print("OK.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright 2015, Kay Hayen, mailto:[email protected] | ||
# | ||
# Python test originally created or extracted from other peoples work. The | ||
# parts from me are licensed as below. It is at least Free Softwar where | ||
# it's copied from other people. In these cases, that will normally be | ||
# indicated. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
def calledRepeatedly(): | ||
# We measure making a generator iterator step or not. | ||
gen = (x for x in range(3)) | ||
|
||
x = next(gen) | ||
# construct_begin | ||
next(gen) | ||
# construct_end | ||
|
||
return x | ||
|
||
for x in xrange(50000): | ||
calledRepeatedly() | ||
|
||
print("OK.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,8 @@ def generator(): | |
next(gen) | ||
# construct_end | ||
|
||
return x | ||
|
||
for x in xrange(50000): | ||
calledRepeatedly() | ||
|
||
|