Code

Opened 9 years ago

Closed 9 years ago

Last modified 3 years ago

#326 closed enhancement (wontfix)

IPAddressField in decimal format

Reported by: Bless Owned by: adrian
Component: Database layer (models, ORM) Version: 1.0
Severity: normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

An IP address is stored in string format and allocating 15 bytes (120 bits)

But it would be possible convert that address to decimal format and store it in less bits.

>>> import socket, struct 
>>> ip = "192.168.2.1"
>>> q = ip.split(".")
>>> n = reduce(lambda a,b: long(a)*256 + long(b), q)
>>> n
3232236033L
>>> socket.inet_ntoa(struct.pack('!I', n))
'192.168.2.1'

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/d4d9d1870a481568/
http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/b2e259d7d55a6071/

Attachments (0)

Change History (2)

comment:1 Changed 9 years ago by adrian

  • Resolution set to wontfix
  • Status changed from new to closed

If you're concerned about using fewer bits, use PostgreSQL, which has a custom IP address column type (which Django uses). Django only uses string formats for MySQL and SQLite.

comment:2 Changed 3 years ago by aaugustin

  • Easy pickings unset
  • UI/UX unset

#17245 was a duplicate.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.