},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"def expand_no_re(text, expansion_limit=None):\n",
" i = 1\n",
" s, e, l, n = find_expansion_mark(text)\n",
- " while s and (expansion_limit is None or (expansion_limit is not None and i <= expansion_limit)):\n",
+ " while s is not None and (expansion_limit is None or (expansion_limit is not None and i <= expansion_limit)):\n",
" text = text[:s-l] + text[s-l:s] * n + text[e+1:]\n",
" s, e, l, n = find_expansion_mark(text)\n",
" i += 1\n",
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": 18,
"metadata": {},
"outputs": [
{
"149043"
]
},
- "execution_count": 8,
+ "execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": 19,
"metadata": {},
"outputs": [
{
"302266"
]
},
- "execution_count": 9,
+ "execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
"metadata": {},
"outputs": [],
"source": [
- "comment_mark = re.compile('<[^>]*>')\n",
- "expand_mark = re.compile(':(\\d+):(\\d+):')"
+ "comment_mark = re.compile('<[^>]*>') # A < followed by some things that aren't > followed by >\n",
+ "expand_mark = re.compile(':(\\d+):(\\d+):') # A : followed by some digits, followed by another :, then some more digits, then a final :"
]
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
},
{
"cell_type": "code",
- "execution_count": 29,
+ "execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
},
{
"cell_type": "code",
- "execution_count": 30,
+ "execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
},
{
"cell_type": "code",
- "execution_count": 31,
+ "execution_count": 7,
"metadata": {},
"outputs": [
{
"149043"
]
},
- "execution_count": 31,
+ "execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 32,
+ "execution_count": 8,
"metadata": {},
"outputs": [
{
"302266"
]
},
- "execution_count": 32,
+ "execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 33,
+ "execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
},
{
"cell_type": "code",
- "execution_count": 34,
+ "execution_count": 10,
"metadata": {},
"outputs": [
{
"149043"
]
},
- "execution_count": 34,
+ "execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 35,
+ "execution_count": 11,
"metadata": {},
"outputs": [
{
"302266"
]
},
- "execution_count": 35,
+ "execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 36,
+ "execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "27.5 ms ± 951 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
+ "27.7 ms ± 908 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
]
}
],
},
{
"cell_type": "code",
- "execution_count": 37,
+ "execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "875 ms ± 5.02 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
+ "861 ms ± 7.25 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
]
}
],