prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  kinto start takes too much time.
  It can sometimes take more than 2 seconds, as reported by @n1k0 on JS clients integration tests.
  
  I investigated a bit and found out, that on my machine, loading the entrypoint takes more than 1 second already:
  
  ```
  $ time python -c "from pkg_resources import load_entry_point; load_entry_point('kinto', 'console_scripts', 'kinto')"
  python -c   0,96s user 0,16s system 99% cpu 1,132 total
  ```
  
  In comparison, `pserve` takes 200msec: 
  
  ```
  $ time python -c "from pkg_resources import load_entry_point; load_entry_point('pyramid', 'console_scripts', 'pcreate')"
  python -c   0,18s user 0,09s system 98% cpu 0,272 total
  ```
  
  I realized that moving `import requests` from `cliquet.initialization` imports [PR](https://github.com/mozilla-services/cliquet/pull/674), and remove `import pip` from `kinto.__main__` I could reduce by half:
  
  ```
  $ time python -c "from pkg_resources import load_entry_point; load_entry_point('kinto', 'console_scripts', 'kinto')"
  python -c   0,36s user 0,18s system 98% cpu 0,543 total
  ```
  
  I knew this was not going to speed up the `kinto start` command too much. I tracked down and noticed the `__main__:main` was executed twice because of `--reload` argument.
  
  
  </issue>
  <code>
  [start of kinto/__main__.py]
  1 from __future__ import print_function
  2 import argparse
  3 import os
  4 import sys
  5 
  6 from six.moves import input
  7 from cliquet.scripts import cliquet
  8 from pyramid.scripts import pserve
  9 from pyramid.paster import bootstrap
  10 from kinto import __version__
  11 from kinto.config import init
  12 
  13 CONFIG_FILE = 'config/kinto.ini'
  14 
  15 
  16 def main(args=None):
  17     """The main routine."""
  18     if args is None:
  19         args = sys.argv[1:]
  20 
  21     parser = argparse.ArgumentParser(description="Kinto commands")
  22     parser.add_argument('--ini',
  23                         help='Application configuration file',
  24                         dest='ini_file',
  25                         required=False,
  26                         default=CONFIG_FILE)
  27     parser.add_argument('--backend',
  28                         help='Specify backend',
  29                         dest='backend',
  30                         required=False,
  31                         default=None)
  32 
  33     parser.add_argument('-v', '--version',
  34                         action='version', version=__version__,
  35                         help='Print the Kinto version and exit.')
  36 
  37     subparsers = parser.add_subparsers(title='subcommands',
  38                                        description='valid subcommands',
  39                                        help='init/start/migrate')
  40 
  41     parser_init = subparsers.add_parser('init')
  42     parser_init.set_defaults(which='init')
  43 
  44     parser_migrate = subparsers.add_parser('migrate')
  45     parser_migrate.set_defaults(which='migrate')
  46 
  47     parser_start = subparsers.add_parser('start')
  48     parser_start.set_defaults(which='start')
  49 
  50     args = vars(parser.parse_args())
  51     config_file = args['ini_file']
  52 
  53     if args['which'] == 'init':
  54         if os.path.exists(config_file):
  55             print("%s already exist." % config_file, file=sys.stderr)
  56             sys.exit(1)
  57 
  58         backend = args['backend']
  59         if not backend:
  60             while True:
  61                 prompt = ("Select the backend you would like to use: "
  62                           "(1 - postgresql, 2 - redis, default - memory) ")
  63                 answer = input(prompt).strip()
  64                 try:
  65                     backends = {"1": "postgresql", "2": "redis", "": "memory"}
  66                     backend = backends[answer]
  67                     break
  68                 except KeyError:
  69                     pass
  70 
  71         init(config_file, backend)
  72 
  73         # Install postgresql libraries if necessary
  74         if backend == "postgresql":
  75             try:
  76                 import psycopg2  # NOQA
  77             except ImportError:
  78                 import pip
  79                 pip.main(['install', "cliquet[postgresql]"])
  80 
  81     elif args['which'] == 'migrate':
  82         env = bootstrap(config_file)
  83         cliquet.init_schema(env)
  84 
  85     elif args['which'] == 'start':
  86         pserve_argv = ['pserve', config_file, '--reload']
  87         pserve.main(pserve_argv)
  88 
  89 
  90 if __name__ == "__main__":
  91     main()
  92
  [end of kinto/__main__.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/kinto/__main__.py b/kinto/__main__.py
  --- a/kinto/__main__.py
  +++ b/kinto/__main__.py
  @@ -45,6 +45,11 @@
       parser_migrate.set_defaults(which='migrate')
   
       parser_start = subparsers.add_parser('start')
  +    parser_start.add_argument('--reload',
  +                              action='store_true',
  +                              help='Restart when code or config changes',
  +                              required=False,
  +                              default=False)
       parser_start.set_defaults(which='start')
   
       args = vars(parser.parse_args())
  @@ -83,7 +88,9 @@
           cliquet.init_schema(env)
   
       elif args['which'] == 'start':
  -        pserve_argv = ['pserve', config_file, '--reload']
  +        pserve_argv = ['pserve', config_file]
  +        if args['reload']:
  +            pserve_argv.append('--reload')
           pserve.main(pserve_argv)
  
verification_info: {"golden_diff": "diff --git a/kinto/__main__.py b/kinto/__main__.py\n--- a/kinto/__main__.py\n+++ b/kinto/__main__.py\n@@ -45,6 +45,11 @@\n     parser_migrate.set_defaults(which='migrate')\n \n     parser_start = subparsers.add_parser('start')\n+    parser_start.add_argument('--reload',\n+                              action='store_true',\n+                              help='Restart when code or config changes',\n+                              required=False,\n+                              default=False)\n     parser_start.set_defaults(which='start')\n \n     args = vars(parser.parse_args())\n@@ -83,7 +88,9 @@\n         cliquet.init_schema(env)\n \n     elif args['which'] == 'start':\n-        pserve_argv = ['pserve', config_file, '--reload']\n+        pserve_argv = ['pserve', config_file]\n+        if args['reload']:\n+            pserve_argv.append('--reload')\n         pserve.main(pserve_argv)\n", "issue": "kinto start takes too much time.\nIt can sometimes take more than 2 seconds, as reported by @n1k0 on JS clients integration tests.\n\nI investigated a bit and found out, that on my machine, loading the entrypoint takes more than 1 second already:\n\n```\n$ time python -c \"from pkg_resources import load_entry_point; load_entry_point('kinto', 'console_scripts', 'kinto')\"\npython -c   0,96s user 0,16s system 99% cpu 1,132 total\n```\n\nIn comparison, `pserve` takes 200msec: \n\n```\n$ time python -c \"from pkg_resources import load_entry_point; load_entry_point('pyramid', 'console_scripts', 'pcreate')\"\npython -c   0,18s user 0,09s system 98% cpu 0,272 total\n```\n\nI realized that moving `import requests` from `cliquet.initialization` imports [PR](https://github.com/mozilla-services/cliquet/pull/674), and remove `import pip` from `kinto.__main__` I could reduce by half:\n\n```\n$ time python -c \"from pkg_resources import load_entry_point; load_entry_point('kinto', 'console_scripts', 'kinto')\"\npython -c   0,36s user 0,18s system 98% cpu 0,543 total\n```\n\nI knew this was not going to speed up the `kinto start` command too much. I tracked down and noticed the `__main__:main` was executed twice because of `--reload` argument.\n\n", "before_files": [{"content": "from __future__ import print_function\nimport argparse\nimport os\nimport sys\n\nfrom six.moves import input\nfrom cliquet.scripts import cliquet\nfrom pyramid.scripts import pserve\nfrom pyramid.paster import bootstrap\nfrom kinto import __version__\nfrom kinto.config import init\n\nCONFIG_FILE = 'config/kinto.ini'\n\n\ndef main(args=None):\n    \"\"\"The main routine.\"\"\"\n    if args is None:\n        args = sys.argv[1:]\n\n    parser = argparse.ArgumentParser(description=\"Kinto commands\")\n    parser.add_argument('--ini',\n                        help='Application configuration file',\n                        dest='ini_file',\n                        required=False,\n                        default=CONFIG_FILE)\n    parser.add_argument('--backend',\n                        help='Specify backend',\n                        dest='backend',\n                        required=False,\n                        default=None)\n\n    parser.add_argument('-v', '--version',\n                        action='version', version=__version__,\n                        help='Print the Kinto version and exit.')\n\n    subparsers = parser.add_subparsers(title='subcommands',\n                                       description='valid subcommands',\n                                       help='init/start/migrate')\n\n    parser_init = subparsers.add_parser('init')\n    parser_init.set_defaults(which='init')\n\n    parser_migrate = subparsers.add_parser('migrate')\n    parser_migrate.set_defaults(which='migrate')\n\n    parser_start = subparsers.add_parser('start')\n    parser_start.set_defaults(which='start')\n\n    args = vars(parser.parse_args())\n    config_file = args['ini_file']\n\n    if args['which'] == 'init':\n        if os.path.exists(config_file):\n            print(\"%s already exist.\" % config_file, file=sys.stderr)\n            sys.exit(1)\n\n        backend = args['backend']\n        if not backend:\n            while True:\n                prompt = (\"Select the backend you would like to use: \"\n                          \"(1 - postgresql, 2 - redis, default - memory) \")\n                answer = input(prompt).strip()\n                try:\n                    backends = {\"1\": \"postgresql\", \"2\": \"redis\", \"\": \"memory\"}\n                    backend = backends[answer]\n                    break\n                except KeyError:\n                    pass\n\n        init(config_file, backend)\n\n        # Install postgresql libraries if necessary\n        if backend == \"postgresql\":\n            try:\n                import psycopg2  # NOQA\n            except ImportError:\n                import pip\n                pip.main(['install', \"cliquet[postgresql]\"])\n\n    elif args['which'] == 'migrate':\n        env = bootstrap(config_file)\n        cliquet.init_schema(env)\n\n    elif args['which'] == 'start':\n        pserve_argv = ['pserve', config_file, '--reload']\n        pserve.main(pserve_argv)\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "kinto/__main__.py"}]}