Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions examples/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@
import timeit

parser = argparse.ArgumentParser(description='Benchmark maxminddb.')
parser.add_argument(
'--count', default=250000, type=int, help='number of lookups')
parser.add_argument('--count',
default=250000,
type=int,
help='number of lookups')
parser.add_argument('--mode', default=0, type=int, help='reader mode to use')
parser.add_argument(
'--file', default='GeoIP2-City.mmdb', help='path to mmdb file')
parser.add_argument('--file',
default='GeoIP2-City.mmdb',
help='path to mmdb file')

args = parser.parse_args()

Expand All @@ -27,9 +30,8 @@ def lookup_ip_address():
record = reader.get(str(ip))


elapsed = timeit.timeit(
'lookup_ip_address()',
setup='from __main__ import lookup_ip_address',
number=args.count)
elapsed = timeit.timeit('lookup_ip_address()',
setup='from __main__ import lookup_ip_address',
number=args.count)

print(args.count / elapsed, 'lookups per second')
1 change: 0 additions & 1 deletion maxminddb/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

class Decoder(object): # pylint: disable=too-few-public-methods
"""Decoder for the data section of the MaxMind DB"""

def __init__(self, database_buffer, pointer_base=0, pointer_test=False):
"""Created a Decoder for a MaxMind DB

Expand Down
1 change: 0 additions & 1 deletion maxminddb/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

class FileBuffer(object):
"""A slice-able file reader"""

def __init__(self, database):
self._handle = open(database, 'rb')
self._size = os.fstat(self._handle.fileno()).st_size
Expand Down
78 changes: 38 additions & 40 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def status_msgs(*msgs):
def find_packages(location):
packages = []
for pkg in ['maxminddb']:
for _dir, subdirectories, files in (os.walk(
os.path.join(location, pkg))):
for _dir, subdirectories, files in (os.walk(os.path.join(
location, pkg))):
if '__init__.py' in files:
tokens = _dir.split(os.sep)[len(location.split(os.sep)):]
packages.append(".".join(tokens))
Expand All @@ -110,48 +110,46 @@ def run_setup(with_cext):
if Feature:
kwargs['features'] = {
'extension':
Feature(
"optional C implementation",
standard=True,
ext_modules=ext_module)
Feature("optional C implementation",
standard=True,
ext_modules=ext_module)
}
else:
kwargs['ext_modules'] = ext_module

setup(
name='maxminddb',
version=VERSION,
author='Gregory Oschwald',
author_email='[email protected]',
description='Reader for the MaxMind DB format',
long_description=README,
url='http://www.maxmind.com/',
packages=find_packages('.'),
package_data={'': ['LICENSE']},
package_dir={'maxminddb': 'maxminddb'},
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*',
include_package_data=True,
install_requires=requirements,
tests_require=['nose'],
test_suite='nose.collector',
license=LICENSE,
cmdclass=cmdclass,
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python',
'Topic :: Internet :: Proxy Servers',
'Topic :: Internet',
],
**kwargs)
setup(name='maxminddb',
version=VERSION,
author='Gregory Oschwald',
author_email='[email protected]',
description='Reader for the MaxMind DB format',
long_description=README,
url='http://www.maxmind.com/',
packages=find_packages('.'),
package_data={'': ['LICENSE']},
package_dir={'maxminddb': 'maxminddb'},
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*',
include_package_data=True,
install_requires=requirements,
tests_require=['nose'],
test_suite='nose.collector',
license=LICENSE,
cmdclass=cmdclass,
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python',
'Topic :: Internet :: Proxy Servers',
'Topic :: Internet',
],
**kwargs)


if PYPY or JYTHON:
Expand Down