小编Kon*_*zin的帖子

ITERATOR列表在std :: string构造函数中被破坏

在VS2005 SP1的Debug配置中编译的以下代码显示了两条带有"ITERATOR LIST CORRUPTED"通知的消息.

代码片段

#define _SECURE_SCL 0
#define _HAS_ITERATOR_DEBUGGING 0

#include <sstream>
#include <string>

int main()
{
  std::stringstream stream;
  stream << "123" << std::endl;
  std::string str = stream.str();
  std::string::const_iterator itFirst = str.begin();
  int position = str.find('2');
  std::string::const_iterator itSecond = itFirst + position;
  std::string tempStr(itFirst,itSecond); ///< errors are here
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

这是编译器或标准库中的错误吗?

c++ visual-c++-2008 visual-c++ visual-c++-2005

7
推荐指数
1
解决办法
2011
查看次数

为什么python + sqlite3非常慢?

我尝试使用"Python 2.7.4 + sqlite3"和"Firefox SQLite Manager 0.8.0"将相同的请求处理到同一个数据库.

在微小的数据库(8000条记录)上,Python和Firefox都可以快速运行并提供相同的结果.

在更大的数据库(2600000记录):

  • SQLite Manager在28秒内处理数据库(24条记录)
  • Python程序已经工作了20分钟而没有任何结果

以下程序可能有什么问题,所以python sqlite3无法在合理的时间内处理查询,同时可以更快地处理相同的请求?

import sqlite3

_sql1 = """SELECT DISTINCT J2.rule_description,
                J2.feature_type,
                J2.action_item_id,
                J2.rule_items
FROM journal J1,
     journal J2
WHERE J1.base = J2.base
    AND J1.action_item_id=J2.action_item_id
    AND J1.type="Action disabled"
    AND J2.type="Action applied"
    AND J1.rule_description="Some test rule"
    AND J1.action_item_id IN (1, 2, 3, 14, 15, 16, 17, 18, 19, 30, 31, 32)
"""

if __name__ == '__main__':
    sqlite_output = r'D:\results.sqlite'
    with sqlite3.connect(sqlite_output) as connection:
        for row in connection.execute(_sql1):
            print row
Run Code Online (Sandbox Code Playgroud)

更新: 命令行Shell对于SQLite …

sqlite performance python-2.7 python-3.x

7
推荐指数
1
解决办法
6627
查看次数