我是靠谱客的博主 重要黑猫,最近开发中收集的这篇文章主要介绍python模糊匹配算法,用于模糊匹配的Python哈希表,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

I am trying to implement a data structure which allows rapid look-ups based on keys.

The python dict is great when my look-ups involve an equality

(e.g. key == somevalue translates to datadict[somevalue].

The problem is that I also need to be able to efficiently look up keys based on a more complex comparison, e.g. key > 50, or key.startswith('abc').

Obviously I can't use the same solution in both cases, but at the moment I can't figure out how to solve either case. Can anyone suggest a way of doing this?

解决方案

It doesn't sound like you want a hash algorithm - instead some form of binary tree. Or even a list which you use the bisect module with. It'd be worth looking at: Python's standard library - is there a module for balanced binary tree?

Another option (depending on your data), would be to use use an in-memory sqlite3 database and create appropriate indices for possible lookups -- but you'll trade performance/memory and SQL syntax for flexibility...

最后

以上就是重要黑猫为你收集整理的python模糊匹配算法,用于模糊匹配的Python哈希表的全部内容,希望文章能够帮你解决python模糊匹配算法,用于模糊匹配的Python哈希表所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(59)

评论列表共有 0 条评论

立即
投稿
返回
顶部