Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
topydo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
topydo
Commits
9c9837c4
Commit
9c9837c4
authored
Nov 29, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some fixes for pylint.
parent
4c02e401
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
topydo/lib/HashListValues.py
topydo/lib/HashListValues.py
+10
-4
No files found.
topydo/lib/HashListValues.py
View file @
9c9837c4
...
...
@@ -14,8 +14,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
_table_sizes
=
{
# we choose a large table size reduce the change of collisions
"""
Module that calculates identifiers for each item in a list, based on the hash
value of each item.
"""
_TABLE_SIZES
=
{
# we choose a large table size to reduce the change of collisions.
3
:
46649
,
# largest prime under zzz_36
4
:
1679609
# largest prime under zzzz_36
}
...
...
@@ -43,7 +48,7 @@ def hash_list_values(p_list, p_hash=hash):
The value is based on hashing an item using the p_hash function.
Suitable for lists not larger than approx. 16K items
Suitable for lists not larger than approx. 16K items
.
Returns a tuple with the status and a list of tuples where each item is
combined with the ID.
...
...
@@ -52,7 +57,8 @@ def hash_list_values(p_list, p_hash=hash):
used
=
set
()
# choose a larger key size if there's >1% chance of collision
size
=
_table_sizes
[
3
]
if
len
(
p_list
)
<
_table_sizes
[
3
]
*
0.01
else
_table_sizes
[
4
]
size
=
_TABLE_SIZES
[
3
]
\
if
len
(
p_list
)
<
_TABLE_SIZES
[
3
]
*
0.01
else
_TABLE_SIZES
[
4
]
for
item
in
p_list
:
hash_value
=
p_hash
(
item
)
%
size
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment