質問編集履歴

3

追記情報を追加

2018/02/01 05:26

投稿

KK-31
KK-31

スコア22

test CHANGED
File without changes
test CHANGED
@@ -27,3 +27,15 @@
27
27
  ```
28
28
 
29
29
  上記コードのように、一応内包表記はしているのですが、速度改善のための方法を教えていただきたいです。
30
+
31
+
32
+
33
+ 追記
34
+
35
+
36
+
37
+ デバッグ可能状態で実行したところ、26秒程度かかっておりましたが、
38
+
39
+ デバッグなしの状態では、全処理に3.515秒となりました。 
40
+
41
+  →アルゴリズム等の問題ではありませんでした。

2

質問に合わせて、プログラムを修正しました。

2018/02/01 05:26

投稿

KK-31
KK-31

スコア22

test CHANGED
File without changes
test CHANGED
@@ -8,9 +8,9 @@
8
8
 
9
9
  ```python
10
10
 
11
- dict1 = {a:100,b:200,c:300...1万データくらい} #例です
11
+ dict1 = {"a":"100","b":"200","c":"300"} #例です。 (大量に辞書リストくらいあることを想定
12
12
 
13
- target_list =[a,b,c,d...100万データくらい] #例です。
13
+ target_list =["a","b","c","d"] #例です。 (大量にデータがある事を想定
14
14
 
15
15
 
16
16
 
@@ -18,6 +18,12 @@
18
18
 
19
19
  new_list = [ list(map(dict(dict1).get, document)) for document in target_list]
20
20
 
21
+ print(new_list)
22
+
23
+ #[['100'], ['200'], ['300'], [None]]
24
+
25
+
26
+
21
27
  ```
22
28
 
23
29
  上記コードのように、一応内包表記はしているのですが、速度改善のための方法を教えていただきたいです。

1

プログラム変更

2018/02/01 02:46

投稿

KK-31
KK-31

スコア22

test CHANGED
File without changes
test CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
 
8
8
 
9
- ```python3
9
+ ```python
10
10
 
11
11
  dict1 = {a:100,b:200,c:300...1万データくらい} #例です
12
12
 
@@ -14,9 +14,9 @@
14
14
 
15
15
 
16
16
 
17
- new list = [] #list初期化
17
+ new_list = [] #list初期化
18
18
 
19
- new list = [ list(map(dict(dict1).get, document)) for document in target_list]
19
+ new_list = [ list(map(dict(dict1).get, document)) for document in target_list]
20
20
 
21
21
  ```
22
22