Can't return wanting type of data using Cython
I want to build a function that can return the most common permutation of six "R" letters plus six "B" letters, the list may looks like this:
a = ['R'] * 6 + ['B'] * 6
random.shuffle(a)
shuffle = ''.join(a)
shuffle
Output: 'BRBRRRBBRBBR'
I want to write a loop of this function to simulate the most common distribution of these strings. I did write a for loop with python and it did work, but after I import cython to accelerate this function, something goes wrong, here is the code:
'''Python Code'''
import random
def random_loop_py(times):
a = ['R'] * 6 + ['B'] * 6
count = {}
for i in range(times):
random.shuffle(a)
shuffle = ''.join(a)
if shuffle in count.keys():
count[shuffle] += 1
else:
count[shuffle] = 1
return count
%timeit random_loop_py(100000)
'''Cython Code'''
%load_ext cython
%%cython
import random
cpdef void random_loop(int size):
a = ['R'] * 6 + ['B'] * 6
count = {}
for i in range(size):
random.shuffle(a)
shuffle = ''.join(a)
if shuffle in count.keys():
count[shuffle] += 1
else:
count[shuffle] = 1
return count.values()
And Error:
Error compiling Cython file:
------------------------------------------------------------
...
shuffle = ''.join(a)
if shuffle in count.keys():
count[shuffle] += 1
else:
count[shuffle] = 1
return count.keys()
^
------------------------------------------------------------
/Users/lee_excited/.ipython/cython/_cython_magic_e70ad62499224c5d4fd4e23d6dcb9e49.pyx:12:21: Return with value in void function
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-120-a09f2e5d5e69> in <module>
----> 1 get_ipython().run_cell_magic('cython', '', "import randomncpdef void random_loop(int size):n a = ['R'] * 6 + ['B'] * 6n count = {}n for i in range(size):n random.shuffle(a)n shuffle = ''.join(a)n if shuffle in count.keys():n count[shuffle] += 1n else:n count[shuffle] = 1n return count.keys()n")
~/anaconda3/lib/python3.6/site-packages/IPython/core/interactiveshell.py in run_cell_magic(self, magic_name, line, cell)
2321 magic_arg_s = self.var_expand(line, stack_depth)
2322 with self.builtin_trap:
-> 2323 result = fn(magic_arg_s, cell)
2324 return result
2325
<decorator-gen-127> in cython(self, line, cell)
~/anaconda3/lib/python3.6/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
185 # but it's overkill for just that one bit of state.
186 def magic_deco(arg):
--> 187 call = lambda f, *a, **k: f(*a, **k)
188
189 if callable(arg):
~/anaconda3/lib/python3.6/site-packages/Cython/Build/IpythonMagic.py in cython(self, line, cell)
323 if need_cythonize:
324 extensions = self._cythonize(module_name, code, lib_dir, args, quiet=args.quiet)
--> 325 assert len(extensions) == 1
326 extension = extensions[0]
327 self._code_cache[key] = module_name
TypeError: object of type 'NoneType' has no len()
What kind of data should I return to accelerate my simulation, please?
python cython cythonize
|
show 1 more comment
I want to build a function that can return the most common permutation of six "R" letters plus six "B" letters, the list may looks like this:
a = ['R'] * 6 + ['B'] * 6
random.shuffle(a)
shuffle = ''.join(a)
shuffle
Output: 'BRBRRRBBRBBR'
I want to write a loop of this function to simulate the most common distribution of these strings. I did write a for loop with python and it did work, but after I import cython to accelerate this function, something goes wrong, here is the code:
'''Python Code'''
import random
def random_loop_py(times):
a = ['R'] * 6 + ['B'] * 6
count = {}
for i in range(times):
random.shuffle(a)
shuffle = ''.join(a)
if shuffle in count.keys():
count[shuffle] += 1
else:
count[shuffle] = 1
return count
%timeit random_loop_py(100000)
'''Cython Code'''
%load_ext cython
%%cython
import random
cpdef void random_loop(int size):
a = ['R'] * 6 + ['B'] * 6
count = {}
for i in range(size):
random.shuffle(a)
shuffle = ''.join(a)
if shuffle in count.keys():
count[shuffle] += 1
else:
count[shuffle] = 1
return count.values()
And Error:
Error compiling Cython file:
------------------------------------------------------------
...
shuffle = ''.join(a)
if shuffle in count.keys():
count[shuffle] += 1
else:
count[shuffle] = 1
return count.keys()
^
------------------------------------------------------------
/Users/lee_excited/.ipython/cython/_cython_magic_e70ad62499224c5d4fd4e23d6dcb9e49.pyx:12:21: Return with value in void function
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-120-a09f2e5d5e69> in <module>
----> 1 get_ipython().run_cell_magic('cython', '', "import randomncpdef void random_loop(int size):n a = ['R'] * 6 + ['B'] * 6n count = {}n for i in range(size):n random.shuffle(a)n shuffle = ''.join(a)n if shuffle in count.keys():n count[shuffle] += 1n else:n count[shuffle] = 1n return count.keys()n")
~/anaconda3/lib/python3.6/site-packages/IPython/core/interactiveshell.py in run_cell_magic(self, magic_name, line, cell)
2321 magic_arg_s = self.var_expand(line, stack_depth)
2322 with self.builtin_trap:
-> 2323 result = fn(magic_arg_s, cell)
2324 return result
2325
<decorator-gen-127> in cython(self, line, cell)
~/anaconda3/lib/python3.6/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
185 # but it's overkill for just that one bit of state.
186 def magic_deco(arg):
--> 187 call = lambda f, *a, **k: f(*a, **k)
188
189 if callable(arg):
~/anaconda3/lib/python3.6/site-packages/Cython/Build/IpythonMagic.py in cython(self, line, cell)
323 if need_cythonize:
324 extensions = self._cythonize(module_name, code, lib_dir, args, quiet=args.quiet)
--> 325 assert len(extensions) == 1
326 extension = extensions[0]
327 self._code_cache[key] = module_name
TypeError: object of type 'NoneType' has no len()
What kind of data should I return to accelerate my simulation, please?
python cython cythonize
Please, post your code and exceptions as text.
– Eli Korvigo
Nov 14 '18 at 12:38
OK, I have added the code.
– Weizhe Li
Nov 14 '18 at 12:44
Remove the screenshots entirely. Including the output.
– Mad Physicist
Nov 14 '18 at 12:50
OK, deleted and rearranged issue structure.
– Weizhe Li
Nov 14 '18 at 12:57
OK, deleted and rearranged issue structure. @MadPhysicist
– Weizhe Li
Nov 14 '18 at 13:03
|
show 1 more comment
I want to build a function that can return the most common permutation of six "R" letters plus six "B" letters, the list may looks like this:
a = ['R'] * 6 + ['B'] * 6
random.shuffle(a)
shuffle = ''.join(a)
shuffle
Output: 'BRBRRRBBRBBR'
I want to write a loop of this function to simulate the most common distribution of these strings. I did write a for loop with python and it did work, but after I import cython to accelerate this function, something goes wrong, here is the code:
'''Python Code'''
import random
def random_loop_py(times):
a = ['R'] * 6 + ['B'] * 6
count = {}
for i in range(times):
random.shuffle(a)
shuffle = ''.join(a)
if shuffle in count.keys():
count[shuffle] += 1
else:
count[shuffle] = 1
return count
%timeit random_loop_py(100000)
'''Cython Code'''
%load_ext cython
%%cython
import random
cpdef void random_loop(int size):
a = ['R'] * 6 + ['B'] * 6
count = {}
for i in range(size):
random.shuffle(a)
shuffle = ''.join(a)
if shuffle in count.keys():
count[shuffle] += 1
else:
count[shuffle] = 1
return count.values()
And Error:
Error compiling Cython file:
------------------------------------------------------------
...
shuffle = ''.join(a)
if shuffle in count.keys():
count[shuffle] += 1
else:
count[shuffle] = 1
return count.keys()
^
------------------------------------------------------------
/Users/lee_excited/.ipython/cython/_cython_magic_e70ad62499224c5d4fd4e23d6dcb9e49.pyx:12:21: Return with value in void function
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-120-a09f2e5d5e69> in <module>
----> 1 get_ipython().run_cell_magic('cython', '', "import randomncpdef void random_loop(int size):n a = ['R'] * 6 + ['B'] * 6n count = {}n for i in range(size):n random.shuffle(a)n shuffle = ''.join(a)n if shuffle in count.keys():n count[shuffle] += 1n else:n count[shuffle] = 1n return count.keys()n")
~/anaconda3/lib/python3.6/site-packages/IPython/core/interactiveshell.py in run_cell_magic(self, magic_name, line, cell)
2321 magic_arg_s = self.var_expand(line, stack_depth)
2322 with self.builtin_trap:
-> 2323 result = fn(magic_arg_s, cell)
2324 return result
2325
<decorator-gen-127> in cython(self, line, cell)
~/anaconda3/lib/python3.6/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
185 # but it's overkill for just that one bit of state.
186 def magic_deco(arg):
--> 187 call = lambda f, *a, **k: f(*a, **k)
188
189 if callable(arg):
~/anaconda3/lib/python3.6/site-packages/Cython/Build/IpythonMagic.py in cython(self, line, cell)
323 if need_cythonize:
324 extensions = self._cythonize(module_name, code, lib_dir, args, quiet=args.quiet)
--> 325 assert len(extensions) == 1
326 extension = extensions[0]
327 self._code_cache[key] = module_name
TypeError: object of type 'NoneType' has no len()
What kind of data should I return to accelerate my simulation, please?
python cython cythonize
I want to build a function that can return the most common permutation of six "R" letters plus six "B" letters, the list may looks like this:
a = ['R'] * 6 + ['B'] * 6
random.shuffle(a)
shuffle = ''.join(a)
shuffle
Output: 'BRBRRRBBRBBR'
I want to write a loop of this function to simulate the most common distribution of these strings. I did write a for loop with python and it did work, but after I import cython to accelerate this function, something goes wrong, here is the code:
'''Python Code'''
import random
def random_loop_py(times):
a = ['R'] * 6 + ['B'] * 6
count = {}
for i in range(times):
random.shuffle(a)
shuffle = ''.join(a)
if shuffle in count.keys():
count[shuffle] += 1
else:
count[shuffle] = 1
return count
%timeit random_loop_py(100000)
'''Cython Code'''
%load_ext cython
%%cython
import random
cpdef void random_loop(int size):
a = ['R'] * 6 + ['B'] * 6
count = {}
for i in range(size):
random.shuffle(a)
shuffle = ''.join(a)
if shuffle in count.keys():
count[shuffle] += 1
else:
count[shuffle] = 1
return count.values()
And Error:
Error compiling Cython file:
------------------------------------------------------------
...
shuffle = ''.join(a)
if shuffle in count.keys():
count[shuffle] += 1
else:
count[shuffle] = 1
return count.keys()
^
------------------------------------------------------------
/Users/lee_excited/.ipython/cython/_cython_magic_e70ad62499224c5d4fd4e23d6dcb9e49.pyx:12:21: Return with value in void function
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-120-a09f2e5d5e69> in <module>
----> 1 get_ipython().run_cell_magic('cython', '', "import randomncpdef void random_loop(int size):n a = ['R'] * 6 + ['B'] * 6n count = {}n for i in range(size):n random.shuffle(a)n shuffle = ''.join(a)n if shuffle in count.keys():n count[shuffle] += 1n else:n count[shuffle] = 1n return count.keys()n")
~/anaconda3/lib/python3.6/site-packages/IPython/core/interactiveshell.py in run_cell_magic(self, magic_name, line, cell)
2321 magic_arg_s = self.var_expand(line, stack_depth)
2322 with self.builtin_trap:
-> 2323 result = fn(magic_arg_s, cell)
2324 return result
2325
<decorator-gen-127> in cython(self, line, cell)
~/anaconda3/lib/python3.6/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
185 # but it's overkill for just that one bit of state.
186 def magic_deco(arg):
--> 187 call = lambda f, *a, **k: f(*a, **k)
188
189 if callable(arg):
~/anaconda3/lib/python3.6/site-packages/Cython/Build/IpythonMagic.py in cython(self, line, cell)
323 if need_cythonize:
324 extensions = self._cythonize(module_name, code, lib_dir, args, quiet=args.quiet)
--> 325 assert len(extensions) == 1
326 extension = extensions[0]
327 self._code_cache[key] = module_name
TypeError: object of type 'NoneType' has no len()
What kind of data should I return to accelerate my simulation, please?
python cython cythonize
python cython cythonize
edited Nov 14 '18 at 12:56
Weizhe Li
asked Nov 14 '18 at 12:36
Weizhe LiWeizhe Li
12
12
Please, post your code and exceptions as text.
– Eli Korvigo
Nov 14 '18 at 12:38
OK, I have added the code.
– Weizhe Li
Nov 14 '18 at 12:44
Remove the screenshots entirely. Including the output.
– Mad Physicist
Nov 14 '18 at 12:50
OK, deleted and rearranged issue structure.
– Weizhe Li
Nov 14 '18 at 12:57
OK, deleted and rearranged issue structure. @MadPhysicist
– Weizhe Li
Nov 14 '18 at 13:03
|
show 1 more comment
Please, post your code and exceptions as text.
– Eli Korvigo
Nov 14 '18 at 12:38
OK, I have added the code.
– Weizhe Li
Nov 14 '18 at 12:44
Remove the screenshots entirely. Including the output.
– Mad Physicist
Nov 14 '18 at 12:50
OK, deleted and rearranged issue structure.
– Weizhe Li
Nov 14 '18 at 12:57
OK, deleted and rearranged issue structure. @MadPhysicist
– Weizhe Li
Nov 14 '18 at 13:03
Please, post your code and exceptions as text.
– Eli Korvigo
Nov 14 '18 at 12:38
Please, post your code and exceptions as text.
– Eli Korvigo
Nov 14 '18 at 12:38
OK, I have added the code.
– Weizhe Li
Nov 14 '18 at 12:44
OK, I have added the code.
– Weizhe Li
Nov 14 '18 at 12:44
Remove the screenshots entirely. Including the output.
– Mad Physicist
Nov 14 '18 at 12:50
Remove the screenshots entirely. Including the output.
– Mad Physicist
Nov 14 '18 at 12:50
OK, deleted and rearranged issue structure.
– Weizhe Li
Nov 14 '18 at 12:57
OK, deleted and rearranged issue structure.
– Weizhe Li
Nov 14 '18 at 12:57
OK, deleted and rearranged issue structure. @MadPhysicist
– Weizhe Li
Nov 14 '18 at 13:03
OK, deleted and rearranged issue structure. @MadPhysicist
– Weizhe Li
Nov 14 '18 at 13:03
|
show 1 more comment
1 Answer
1
active
oldest
votes
Your function has a void
return type:
cpdef void random_loop(int size):
...
return count.values()
Consequently, you are not supposed to return anything from it, and the exception message is very clear on that. Change the return type to list
:
cpdef list random_loop(int size):
...
return list(count.values())
P.S.
Your function is not very Cython-friendly: I don't think you will get significant performance improvements.
Update
I can't reproduce your error after the fix
In [9]: %%cython
...: import random
...: cpdef list random_loop(int size):
...: a = ['R'] * 6 + ['B'] * 6
...: count = {}
...: for i in range(size):
...: random.shuffle(a)
...: shuffle = ''.join(a)
...: if shuffle in count.keys():
...: count[shuffle] += 1
...: else:
...: count[shuffle] = 1
...: return list(count.values())
...:
In [10]: random_loop(10)
Out[10]: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
As you can see, it compiles perfectly fine.
Tried, still Error /(ㄒoㄒ)/~~
– Weizhe Li
Nov 14 '18 at 12:45
@WeizheLi You should clarify whether that is the same error or a new one
– Eli Korvigo
Nov 14 '18 at 12:45
Same error as previous one.
– Weizhe Li
Nov 14 '18 at 12:46
Actually I tried print(count.values()) and it works, about 10 times acceleration, so I tried to directly return the dict, but something went wrong. sad.
– Weizhe Li
Nov 14 '18 at 12:48
@WeizheLi I can't reproduce your error. See the update
– Eli Korvigo
Nov 14 '18 at 12:49
|
show 11 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53300403%2fcant-return-wanting-type-of-data-using-cython%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your function has a void
return type:
cpdef void random_loop(int size):
...
return count.values()
Consequently, you are not supposed to return anything from it, and the exception message is very clear on that. Change the return type to list
:
cpdef list random_loop(int size):
...
return list(count.values())
P.S.
Your function is not very Cython-friendly: I don't think you will get significant performance improvements.
Update
I can't reproduce your error after the fix
In [9]: %%cython
...: import random
...: cpdef list random_loop(int size):
...: a = ['R'] * 6 + ['B'] * 6
...: count = {}
...: for i in range(size):
...: random.shuffle(a)
...: shuffle = ''.join(a)
...: if shuffle in count.keys():
...: count[shuffle] += 1
...: else:
...: count[shuffle] = 1
...: return list(count.values())
...:
In [10]: random_loop(10)
Out[10]: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
As you can see, it compiles perfectly fine.
Tried, still Error /(ㄒoㄒ)/~~
– Weizhe Li
Nov 14 '18 at 12:45
@WeizheLi You should clarify whether that is the same error or a new one
– Eli Korvigo
Nov 14 '18 at 12:45
Same error as previous one.
– Weizhe Li
Nov 14 '18 at 12:46
Actually I tried print(count.values()) and it works, about 10 times acceleration, so I tried to directly return the dict, but something went wrong. sad.
– Weizhe Li
Nov 14 '18 at 12:48
@WeizheLi I can't reproduce your error. See the update
– Eli Korvigo
Nov 14 '18 at 12:49
|
show 11 more comments
Your function has a void
return type:
cpdef void random_loop(int size):
...
return count.values()
Consequently, you are not supposed to return anything from it, and the exception message is very clear on that. Change the return type to list
:
cpdef list random_loop(int size):
...
return list(count.values())
P.S.
Your function is not very Cython-friendly: I don't think you will get significant performance improvements.
Update
I can't reproduce your error after the fix
In [9]: %%cython
...: import random
...: cpdef list random_loop(int size):
...: a = ['R'] * 6 + ['B'] * 6
...: count = {}
...: for i in range(size):
...: random.shuffle(a)
...: shuffle = ''.join(a)
...: if shuffle in count.keys():
...: count[shuffle] += 1
...: else:
...: count[shuffle] = 1
...: return list(count.values())
...:
In [10]: random_loop(10)
Out[10]: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
As you can see, it compiles perfectly fine.
Tried, still Error /(ㄒoㄒ)/~~
– Weizhe Li
Nov 14 '18 at 12:45
@WeizheLi You should clarify whether that is the same error or a new one
– Eli Korvigo
Nov 14 '18 at 12:45
Same error as previous one.
– Weizhe Li
Nov 14 '18 at 12:46
Actually I tried print(count.values()) and it works, about 10 times acceleration, so I tried to directly return the dict, but something went wrong. sad.
– Weizhe Li
Nov 14 '18 at 12:48
@WeizheLi I can't reproduce your error. See the update
– Eli Korvigo
Nov 14 '18 at 12:49
|
show 11 more comments
Your function has a void
return type:
cpdef void random_loop(int size):
...
return count.values()
Consequently, you are not supposed to return anything from it, and the exception message is very clear on that. Change the return type to list
:
cpdef list random_loop(int size):
...
return list(count.values())
P.S.
Your function is not very Cython-friendly: I don't think you will get significant performance improvements.
Update
I can't reproduce your error after the fix
In [9]: %%cython
...: import random
...: cpdef list random_loop(int size):
...: a = ['R'] * 6 + ['B'] * 6
...: count = {}
...: for i in range(size):
...: random.shuffle(a)
...: shuffle = ''.join(a)
...: if shuffle in count.keys():
...: count[shuffle] += 1
...: else:
...: count[shuffle] = 1
...: return list(count.values())
...:
In [10]: random_loop(10)
Out[10]: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
As you can see, it compiles perfectly fine.
Your function has a void
return type:
cpdef void random_loop(int size):
...
return count.values()
Consequently, you are not supposed to return anything from it, and the exception message is very clear on that. Change the return type to list
:
cpdef list random_loop(int size):
...
return list(count.values())
P.S.
Your function is not very Cython-friendly: I don't think you will get significant performance improvements.
Update
I can't reproduce your error after the fix
In [9]: %%cython
...: import random
...: cpdef list random_loop(int size):
...: a = ['R'] * 6 + ['B'] * 6
...: count = {}
...: for i in range(size):
...: random.shuffle(a)
...: shuffle = ''.join(a)
...: if shuffle in count.keys():
...: count[shuffle] += 1
...: else:
...: count[shuffle] = 1
...: return list(count.values())
...:
In [10]: random_loop(10)
Out[10]: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
As you can see, it compiles perfectly fine.
edited Nov 14 '18 at 12:53
answered Nov 14 '18 at 12:41
Eli KorvigoEli Korvigo
6,12022747
6,12022747
Tried, still Error /(ㄒoㄒ)/~~
– Weizhe Li
Nov 14 '18 at 12:45
@WeizheLi You should clarify whether that is the same error or a new one
– Eli Korvigo
Nov 14 '18 at 12:45
Same error as previous one.
– Weizhe Li
Nov 14 '18 at 12:46
Actually I tried print(count.values()) and it works, about 10 times acceleration, so I tried to directly return the dict, but something went wrong. sad.
– Weizhe Li
Nov 14 '18 at 12:48
@WeizheLi I can't reproduce your error. See the update
– Eli Korvigo
Nov 14 '18 at 12:49
|
show 11 more comments
Tried, still Error /(ㄒoㄒ)/~~
– Weizhe Li
Nov 14 '18 at 12:45
@WeizheLi You should clarify whether that is the same error or a new one
– Eli Korvigo
Nov 14 '18 at 12:45
Same error as previous one.
– Weizhe Li
Nov 14 '18 at 12:46
Actually I tried print(count.values()) and it works, about 10 times acceleration, so I tried to directly return the dict, but something went wrong. sad.
– Weizhe Li
Nov 14 '18 at 12:48
@WeizheLi I can't reproduce your error. See the update
– Eli Korvigo
Nov 14 '18 at 12:49
Tried, still Error /(ㄒoㄒ)/~~
– Weizhe Li
Nov 14 '18 at 12:45
Tried, still Error /(ㄒoㄒ)/~~
– Weizhe Li
Nov 14 '18 at 12:45
@WeizheLi You should clarify whether that is the same error or a new one
– Eli Korvigo
Nov 14 '18 at 12:45
@WeizheLi You should clarify whether that is the same error or a new one
– Eli Korvigo
Nov 14 '18 at 12:45
Same error as previous one.
– Weizhe Li
Nov 14 '18 at 12:46
Same error as previous one.
– Weizhe Li
Nov 14 '18 at 12:46
Actually I tried print(count.values()) and it works, about 10 times acceleration, so I tried to directly return the dict, but something went wrong. sad.
– Weizhe Li
Nov 14 '18 at 12:48
Actually I tried print(count.values()) and it works, about 10 times acceleration, so I tried to directly return the dict, but something went wrong. sad.
– Weizhe Li
Nov 14 '18 at 12:48
@WeizheLi I can't reproduce your error. See the update
– Eli Korvigo
Nov 14 '18 at 12:49
@WeizheLi I can't reproduce your error. See the update
– Eli Korvigo
Nov 14 '18 at 12:49
|
show 11 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53300403%2fcant-return-wanting-type-of-data-using-cython%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please, post your code and exceptions as text.
– Eli Korvigo
Nov 14 '18 at 12:38
OK, I have added the code.
– Weizhe Li
Nov 14 '18 at 12:44
Remove the screenshots entirely. Including the output.
– Mad Physicist
Nov 14 '18 at 12:50
OK, deleted and rearranged issue structure.
– Weizhe Li
Nov 14 '18 at 12:57
OK, deleted and rearranged issue structure. @MadPhysicist
– Weizhe Li
Nov 14 '18 at 13:03