A bit off topic, but good web hosting for PostgreSQL/Python?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dananrg@yahoo.com

    #1

    A bit off topic, but good web hosting for PostgreSQL/Python?

    Seems like most web hosting providers support MySQL, but not
    PostgreSQL. I need a web hosting account that supports PostgreSQL for a
    particular personal project I'm working on (as well as Python, natch),
    since PostGIS runs only on PostgreSQL. PostGIS is a nice open source
    spatial database extension to PostgreSQL that allows you to store
    geometry in the database.

    Couldn't find a good PostgreSQL newsgroup so I thought I'd ask here.
    Did find one weird one named Mailing something or other, but that may
    be a gateway to a e-mail distribution list.

  • Francisco Reyes

    #2
    Re: A bit off topic, but good web hosting for PostgreSQL/Python?

    dananrg@yahoo.c om writes:
    [color=blue]
    > Seems like most web hosting providers support MySQL, but not
    > PostgreSQL.[/color]

    There are actually many.

    Two that I personally have experience with:



    They both support PostgreSQL.

    Not sure on their python support, but I believe they likely already have it
    or would do mod_python for you.
    [color=blue]
    > Couldn't find a good PostgreSQL newsgroup so I thought I'd ask here.[/color]

    The postgresql mailing lists are both active and very helpfull. Just check
    the postgresql site for mailing list subscription info.

    Comment

    • egbert

      #3
      An isalpha() that accepts underscores as well

      The string method isalpha() returns True when all characters in the
      string are alphabetic. Unfortunately the underscore is not alphabetic.
      A function that does what I need is:

      def alfa_(w):
      return "".join(w.split ("_")).isalpha( )

      but for the kind of strings that I have this is about ten times
      slower than isalpha() sec. Any suggestions ?
      Thanks.
      --
      Egbert Bouwman - Keizersgracht 197 II - 1016 DS Amsterdam - 020 6257991
      =============== =============== =============== =============== ============

      Comment

      • bearophileHUGS@lycos.com

        #4
        Re: An isalpha() that accepts underscores as well

        This is probably faster:

        def alfa_(w):
        return w.replace("_", "a").isalph a()


        This is another solution, but it's probably slower, you can time it:

        from string import letters
        _setalpha = set(letters + "_")

        def alfa_2(w):
        return not (set(w) - _setalpha)

        Bye,
        bearophile

        Comment

        • Zajcev Evgeny

          #5
          Re: An isalpha() that accepts underscores as well

          egbert <egbert.bouwman @hccnet.nl> writes:
          [color=blue]
          > The string method isalpha() returns True when all characters in the
          > string are alphabetic. Unfortunately the underscore is not alphabetic.
          > A function that does what I need is:
          >
          > def alfa_(w):
          > return "".join(w.split ("_")).isalpha( )
          >
          > but for the kind of strings that I have this is about ten times
          > slower than isalpha() sec. Any suggestions ?
          > Thanks.[/color]

          what about

          def alfa_(w):
          return w.isalpha() or w.find('_') != -1

          ? but yes it does scan `w' twice ..

          You could also do something like:

          def alfa_(w):
          for c in w:
          if not c.isalpha() and not c == '_':
          return False
          return True

          --
          lg

          Comment

          • Fuzzyman

            #6
            Re: An isalpha() that accepts underscores as well


            Zajcev Evgeny wrote:[color=blue]
            > egbert <egbert.bouwman @hccnet.nl> writes:
            >[color=green]
            > > The string method isalpha() returns True when all characters in the
            > > string are alphabetic. Unfortunately the underscore is not alphabetic.
            > > A function that does what I need is:
            > >
            > > def alfa_(w):
            > > return "".join(w.split ("_")).isalpha( )
            > >
            > > but for the kind of strings that I have this is about ten times
            > > slower than isalpha() sec. Any suggestions ?
            > > Thanks.[/color]
            >
            > what about
            >
            > def alfa_(w):
            > return w.isalpha() or w.find('_') != -1
            >[/color]

            That returns True if 'w' contains an underscore. The spec is to return
            True if 'w' contains *only* alphaebtical characters and '_'.

            alfa('%^_*&')

            would return True here.
            [color=blue]
            > ? but yes it does scan `w' twice ..
            >
            > You could also do something like:
            >
            > def alfa_(w):
            > for c in w:
            > if not c.isalpha() and not c == '_':
            > return False
            > return True
            >[/color]

            Part of the problem is that the string method 'isalpha' is implemented
            in C, and so will be quicker than any pure Python alternative.

            The following will work, and probably only be twice as slow as
            'isalpha' :-) :

            def alfa(w):
            return w.replace('_', '').isalpha()

            Fuzzyman
            http://www.voidspace.org.uk/python/index.shtml
            [color=blue]
            > --
            > lg[/color]

            Comment

            • Zajcev Evgeny

              #7
              Re: An isalpha() that accepts underscores as well

              "Fuzzyman" <fuzzyman@gmail .com> writes:
              [color=blue]
              > Zajcev Evgeny wrote:[color=green]
              >> egbert <egbert.bouwman @hccnet.nl> writes:
              >>[color=darkred]
              >> > The string method isalpha() returns True when all characters in the
              >> > string are alphabetic. Unfortunately the underscore is not alphabetic.
              >> > A function that does what I need is:
              >> >
              >> > def alfa_(w):
              >> > return "".join(w.split ("_")).isalpha( )
              >> >
              >> > but for the kind of strings that I have this is about ten times
              >> > slower than isalpha() sec. Any suggestions ?
              >> > Thanks.[/color]
              >>
              >> what about
              >>
              >> def alfa_(w):
              >> return w.isalpha() or w.find('_') != -1
              >>[/color]
              >
              > That returns True if 'w' contains an underscore. The spec is to return
              > True if 'w' contains *only* alphaebtical characters and '_'.
              >[/color]

              true, my fault :-< !
              [color=blue]
              > alfa('%^_*&')
              >
              > would return True here.
              >[color=green]
              >> ? but yes it does scan `w' twice ..
              >>
              >> You could also do something like:
              >>
              >> def alfa_(w):
              >> for c in w:
              >> if not c.isalpha() and not c == '_':
              >> return False
              >> return True
              >>[/color]
              >
              > Part of the problem is that the string method 'isalpha' is implemented
              > in C, and so will be quicker than any pure Python alternative.
              >[/color]

              I've been suspecting this ..
              [color=blue]
              > The following will work, and probably only be twice as slow as
              > 'isalpha' :-) :
              >
              > def alfa(w):
              > return w.replace('_', '').isalpha()[/color]

              Yeah, great performance indeed, thanks!

              --
              lg

              Comment

              • Alex Martelli

                #8
                Re: An isalpha() that accepts underscores as well

                Zajcev Evgeny <zevlg@yandex.r u> wrote:
                ...[color=blue][color=green]
                > > The following will work, and probably only be twice as slow as
                > > 'isalpha' :-) :
                > >
                > > def alfa(w):
                > > return w.replace('_', '').isalpha()[/color]
                >
                > Yeah, great performance indeed, thanks![/color]

                Except it rejects a w that's JUST an underscore, while it would accept a
                w that's just a letter, which seems weird to me. Using 'a' as the
                second argument of the replace call, as somebody else suggested, appears
                to produce a more sensible uniformity.


                Alex

                Comment

                • egbert

                  #9
                  Re: An isalpha() that accepts underscores as well

                  In the discussion about isalpha()_mutan ts that accept
                  underscores as well, we did not talk about regular expressions.

                  Afterwards I did some timings.
                  My first observation was that the whole experiment is rather futile,
                  because it takes only about a second to do a million tests.
                  If you take the trouble to collect a million words,
                  you might as well spend an extra second to analyze them.

                  Apart from that, a simple regular expression is often faster
                  than a test with replace. The last one, replace, does better
                  with shorter tokens without underscores. Nothing to replace.
                  Regular expressions are less sensitive to the length of the tokens.
                  Regular expressions are not monsters of inefficiency.

                  This is my script:

                  #!/usr/bin/env python
                  import sys
                  from timeit import Timer

                  import re
                  pat = re.compile(r'^[a-zA-Z_]+$')

                  if len(sys.argv) > 1:
                  token = sys.argv[1]
                  else:
                  token = "contains_under score"

                  t = Timer("''.join( token.split('_' )).isalpha()", "from __main__ import token")
                  print t.timeit() # 1.94

                  t = Timer("token.re place('_','X'). isalpha()", "from __main__ import token")
                  print t.timeit() # 1.36

                  t = Timer("pat.sear ch(token)", "from __main__ import token, pat")
                  print t.timeit() # 1.18

                  t = Timer("token.is alpha()", "from __main__ import token")
                  print t.timeit() # 0.28

                  #egbert

                  --
                  Egbert Bouwman - Keizersgracht 197 II - 1016 DS Amsterdam - 020 6257991
                  =============== =============== =============== =============== ============

                  Comment

                  Working...