小编Eži*_*ulį的帖子

cpoll_cppsp框架是否类型安全为Ur/Web?

看看这个答案(/sf/answers/199987301/)我假设Ur/Web是相当安全的平台.

现在看一下这个基准测试(http://www.techempower.com/benchmarks/#section=data-r9&hw=peak&test=json),我看到cpoll_cppsp框架在大多数用例中排在第1位或排在前5位.

来自(http://xa.us.to/cppsp/documentation.cppsp)的示例代码是

<%#
#include <vector>
#include <string>
vector<string> hello() {
return {"hello", "world", "!"};
}
%>
<html>
<body>
    <table>
        auto a = hello();
        for(int i = 0; i < a.size(); i++) {
            %>
            <tr>
                <td><%=a[i] %></td>
            </tr>
            <%
        }
        %>
    </table>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

文档相当差,所以也许有人可以解释这个类型安全的东西,并具有类似的功能(在此列出:https://stackoverflow.com/a/2856961/1793629)作为Ur/Web?

先感谢您.

c++ frameworks type-safety web

5
推荐指数
1
解决办法
5759
查看次数

奇怪的字典迭代顺序

可能重复:
为什么python会这样排序我的字典?

我有这个完全正常工作的代码,但它的行为很奇怪:字典中的项目不是按顺序迭代,而是以某种方式随机迭代,为什么会这样?:

#!/usr/bin/python

newDict = {}
lunar = {'a':'0','b':'0','c':'0','d':'0','e':'0','f':'0'}
moon = {'a':'1','d':'1','c':'1'}

for il, jl in lunar.items():
    print "lunar: " + il + "." + jl 
    for im, jm in moon.items():
        if il == im:
            newDict[il] = jm
            break
        else:
            newDict[il] = jl

print newDict
Run Code Online (Sandbox Code Playgroud)

输出:

lunar: a.0
lunar: c.0
lunar: b.0
lunar: e.0  
lunar: d.0
lunar: f.0
{'a': '1', 'c': '1', 'b': '0', 'e': '0', 'd': '1', 'f': '0'}
Run Code Online (Sandbox Code Playgroud)

python dictionary

2
推荐指数
1
解决办法
1717
查看次数

标签 统计

c++ ×1

dictionary ×1

frameworks ×1

python ×1

type-safety ×1

web ×1