are they? hashtables shouldn't be too sensitive to key size, as
long as the string size stays bounded... like on IP addresses (max 15
chars)
of course, i don't know about the specific dict implementation on
Python. Sounds like a job for a microbenchmark!
--
Javier
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
OTOH, for really huge database tables, making the index 4 times
smaller can be a significant difference on RAM-starved servers....
but to fill 1G can hold something like of 50million IP addresses in
text form...
--
Javier
From a quick look, it doesn't seem to support IPv6 (which is a real
problem in year 2011 when all IPv4 addresses are allocated). So I
would be -1 on it. There is also the problem of signed int.
PS. Cross-posting like this to django-users and django-developers is
probably not a good idea as people on django-users will send emails
here by accident.
--
Łukasz Rekucki
--
Best wishes,
Dmitry Gladkov, mailto:dmitry....@gmail.com
On Mon, Jul 18, 2011 at 6:21 PM, Javier Guerra Giraldez
> --
> You received this message because you are subscribed to the Google Groups "Django developers" group.
> To post to this group, send email to django-d...@googlegroups.com.
> To unsubscribe from this group, send email to django-develop...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
>
>
On 18 July 2011 16:56, Cal Leeming [Simplicity Media Ltd]
<cal.l...@simplicitymedialtd.co.uk> wrote:
> Hi,From a quick look, it doesn't seem to support IPv6 (which is a real
> I have created a ModelField called RealIPAddressField.
> It stores the IP address in integer form, meaning the lookups on large
> tables are much faster:
> http://djangosnippets.org/snippets/2493/
> @django-developers - Do you think there is any possibility of this getting
> included into the core?
problem in year 2011 when all IPv4 addresses are allocated). So I
would be -1 on it. There is also the problem of signed int.
PS. Cross-posting like this to django-users and django-developers is
probably not a good idea as people on django-users will send emails
here by accident.
--
Łukasz Rekucki
Cal, this may be too late (considering you are already proposing this
for core!), but there are nicer ways of doing this. I use
django-postgresql-netfields [1], which does require postgres as the
name suggests. This library supports (well, exposes postgres's
excellent inet support) ipv4, ipv6, CIDR masks etc, and allows you to
perform complex inet queries using the elegance of django's ORM:
ip=request.META['REMOTE_ADDR']
IPAuth.objects.filter(addr__net_contains_or_equals=ip)
Cheers
Tom
On Mon, Jul 18, 2011 at 3:56 PM, Cal Leeming [Simplicity Media Ltd]
<cal.l...@simplicitymedialtd.co.uk> wrote:
Cal, this may be too late (considering you are already proposing this> Hi,
> I have created a ModelField called RealIPAddressField.
> It stores the IP address in integer form, meaning the lookups on large
> tables are much faster:
> http://djangosnippets.org/snippets/2493/
> @django-developers - Do you think there is any possibility of this getting
> included into the core?
> @django-users - Hope this is of some use to someone else, would appreciate
> any criticisms / improvements.
> Cal
>
for core!), but there are nicer ways of doing this. I use
django-postgresql-netfields [1], which does require postgres as the
name suggests. This library supports (well, exposes postgres's
excellent inet support) ipv4, ipv6, CIDR masks etc, and allows you to
perform complex inet queries using the elegance of django's ORM:
ip=request.META['REMOTE_ADDR']
IPAuth.objects.filter(addr__net_contains_or_equals=ip)
Cheers
Tom
[1] https://github.com/adamcik/django-postgresql-netfields
--
The snippet seems to have been removed (returns "page not found").<snip>
I
was curious to have a look at how you were handling this. For sure,
Postgres has native support for ipv4 and ipv6 address storage. AFAIK,
MySQL does not... although could store an ipv4 address in a 32-bit
unsigned int field. I don't know of any DB engines that support 128
bit ints however (for ipv6).
Django 1.4 alpha already uses Postgres' 'inet' field type for
IPAddressField and GenericIPAddressField. Other DB backends use
varchar(15) and varchar(39) respectively - which probably leads to
some interest sorting side effects.
--