|
@@ -103,8 +103,6 @@
|
|
|
"metadata": {},
|
|
|
"outputs": [],
|
|
|
"source": [
|
|
|
- "import csv \n",
|
|
|
- "\n",
|
|
|
"class Inventory(): \n",
|
|
|
" \n",
|
|
|
" def __init__(self, csv_filename):\n",
|
|
@@ -158,8 +156,6 @@
|
|
|
"metadata": {},
|
|
|
"outputs": [],
|
|
|
"source": [
|
|
|
- "import csv \n",
|
|
|
- "\n",
|
|
|
"class Inventory(): \n",
|
|
|
" \n",
|
|
|
" def __init__(self, csv_filename):\n",
|
|
@@ -293,8 +289,6 @@
|
|
|
"metadata": {},
|
|
|
"outputs": [],
|
|
|
"source": [
|
|
|
- "import csv \n",
|
|
|
- "\n",
|
|
|
"class Inventory(): \n",
|
|
|
" \n",
|
|
|
" def __init__(self, csv_filename):\n",
|
|
@@ -362,12 +356,10 @@
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
- "execution_count": 5,
|
|
|
+ "execution_count": 4,
|
|
|
"metadata": {},
|
|
|
"outputs": [],
|
|
|
"source": [
|
|
|
- "import csv \n",
|
|
|
- "\n",
|
|
|
"class Inventory(): \n",
|
|
|
" \n",
|
|
|
" def __init__(self, csv_filename):\n",
|
|
@@ -424,7 +416,7 @@
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
- "execution_count": 6,
|
|
|
+ "execution_count": 5,
|
|
|
"metadata": {},
|
|
|
"outputs": [
|
|
|
{
|
|
@@ -453,15 +445,15 @@
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
- "execution_count": 12,
|
|
|
+ "execution_count": 9,
|
|
|
"metadata": {},
|
|
|
"outputs": [
|
|
|
{
|
|
|
"name": "stdout",
|
|
|
"output_type": "stream",
|
|
|
"text": [
|
|
|
- "0.7781209945678711\n",
|
|
|
- "0.0003719329833984375\n"
|
|
|
+ "0.3767249584197998\n",
|
|
|
+ "0.00017142295837402344\n"
|
|
|
]
|
|
|
}
|
|
|
],
|
|
@@ -470,22 +462,22 @@
|
|
|
"\n",
|
|
|
"inventory = Inventory('laptops.csv') # step 2\n",
|
|
|
"\n",
|
|
|
- "total_time_no_dict = 0 # step 3\n",
|
|
|
+ "total_time_no_set = 0 # step 3\n",
|
|
|
"for price in prices: # step 4\n",
|
|
|
" start = time.time() # step 4.1\n",
|
|
|
" inventory.check_promotion_dollars(price) # step 4.2\n",
|
|
|
" end = time.time() # step 4.3\n",
|
|
|
- " total_time_no_dict += end - start # step 4.4\n",
|
|
|
+ " total_time_no_set += end - start # step 4.4\n",
|
|
|
" \n",
|
|
|
- "total_time_dict = 0 # step 5\n",
|
|
|
+ "total_time_set = 0 # step 5\n",
|
|
|
"for price in prices: # step 6\n",
|
|
|
" start = time.time() # step 6.1\n",
|
|
|
" inventory.check_promotion_dollars_fast(price) # step 6.2\n",
|
|
|
" end = time.time() # step 6.3\n",
|
|
|
- " total_time_dict += end - start # step 6.4\n",
|
|
|
+ " total_time_set += end - start # step 6.4\n",
|
|
|
" \n",
|
|
|
- "print(total_time_no_dict) # step 7\n",
|
|
|
- "print(total_time_dict)"
|
|
|
+ "print(total_time_no_set) # step 7\n",
|
|
|
+ "print(total_time_set)"
|
|
|
]
|
|
|
},
|
|
|
{
|
|
@@ -528,8 +520,6 @@
|
|
|
}
|
|
|
],
|
|
|
"source": [
|
|
|
- "import csv \n",
|
|
|
- "\n",
|
|
|
"def row_price(row):\n",
|
|
|
" return row[-1]\n",
|
|
|
"\n",
|