467,135 Members | 1,195 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,135 developers. It's quick & easy.

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.

Feb 25 '06 #1
  • viewed: 1862
Share:
8 Replies
da*****@yahoo.com writes:
Seems like most web hosting providers support MySQL, but not
PostgreSQL.
There are actually many.

Two that I personally have experience with:
http://hub.org
http://bizintegrators.com

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.
Couldn't find a good PostgreSQL newsgroup so I thought I'd ask here.


The postgresql mailing lists are both active and very helpfull. Just check
the postgresql site for mailing list subscription info.
Feb 25 '06 #2
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
================================================== ======================
Feb 26 '06 #3
This is probably faster:

def alfa_(w):
return w.replace("_", "a").isalpha()
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

Feb 26 '06 #4
egbert <eg************@hccnet.nl> writes:
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.


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
Feb 26 '06 #5

Zajcev Evgeny wrote:
egbert <eg************@hccnet.nl> writes:
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.
what about

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


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.
? 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

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
--
lg


Feb 26 '06 #6
"Fuzzyman" <fu******@gmail.com> writes:
Zajcev Evgeny wrote:
egbert <eg************@hccnet.nl> writes:
> 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.
what about

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


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


true, my fault :-< !
alfa('%^_*&')

would return True here.
? 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

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


I've been suspecting this ..
The following will work, and probably only be twice as slow as
'isalpha' :-) :

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


Yeah, great performance indeed, thanks!

--
lg
Feb 26 '06 #7
Zajcev Evgeny <ze***@yandex.ru> wrote:
...
The following will work, and probably only be twice as slow as
'isalpha' :-) :

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


Yeah, great performance indeed, thanks!


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
Feb 26 '06 #8
In the discussion about isalpha()_mutants 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_underscore"

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

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

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

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

#egbert

--
Egbert Bouwman - Keizersgracht 197 II - 1016 DS Amsterdam - 020 6257991
================================================== ======================
Mar 1 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by W. Borgert | last post: by
1 post views Thread by Mateusz [PEYN] Adamus | last post: by
reply views Thread by B.r.K.o.N.j.A. | last post: by
6 posts views Thread by MaRcElO PeReIrA | last post: by
13 posts views Thread by Erick Papadakis | last post: by
14 posts views Thread by Manuel Tejada | last post: by
reply views Thread by Adam Smith | last post: by
4 posts views Thread by walterbyrd | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.