Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
4649e2f1
Commit
4649e2f1
authored
May 14, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
another benchmark optimisation
parent
a19bc7f4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
Demos/benchmarks/nqueens.py
Demos/benchmarks/nqueens.py
+2
-2
No files found.
Demos/benchmarks/nqueens.py
View file @
4649e2f1
...
...
@@ -21,7 +21,7 @@ except ImportError:
from
__builtin__
import
xrange
as
_xrange
# Pure-Python implementation of itertools.permutations().
@
cython
.
locals
(
n
=
int
,
i
=
int
)
@
cython
.
locals
(
n
=
int
,
i
=
int
,
j
=
int
)
def
permutations
(
iterable
):
"""permutations(range(3), 2) --> (0,1) (0,2) (1,0) (1,2) (2,0) (2,1)"""
pool
=
tuple
(
iterable
)
...
...
@@ -30,7 +30,7 @@ def permutations(iterable):
cycles
=
list
(
range
(
1
,
n
+
1
))[::
-
1
]
yield
[
pool
[
i
]
for
i
in
indices
]
while
n
:
for
i
in
r
ange
(
n
-
1
,
-
1
,
-
1
):
for
i
in
r
eversed
(
range
(
n
)
):
cycles
[
i
]
-=
1
if
cycles
[
i
]
==
0
:
indices
[
i
:]
=
indices
[
i
+
1
:]
+
indices
[
i
:
i
+
1
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment