from PyPmx import PmxInterface
pmx = PmxInterface()
def readCmos(addr):
pmx.IoWrite8(0x70, addr | (1 << 7))
return pmx.IoRead8(0x71)
def printCmosTime():
hours = readCmos(4)
minutes = readCmos(2)
seconds = readCmos(0)
print ("time: %x:%x.%x" % (hours, minutes, seconds))
def printCmosDbg():
print ("dbg: %x" % (readCmos(0xe)))
printCmosTime()
printCmosDbg()
def get_proxy(self):
while self.list:
proxy = self.list.pop(0)
url = 'http://' + proxy
try:
r = requests.get('http://ya.ru', proxies = {'http': url})
if r.status_code ==200:
self.list.append(proxy)
return url
except requests.exceptions.ConnectionError:
continue
How are lists implemented in CPython?¶
CPython’s lists are really variable-length arrays, not Lisp-style linked lists. The implementation uses a contiguous array of references to other objects, and keeps a pointer to this array and the array’s length in a list head structure.
This makes indexing a list a[i] an operation whose cost is independent of the size of the list or the value of the index.
When items are appended or inserted, the array of references is resized. Some cleverness is applied to improve the performance of appending items repeatedly; when the array must be grown, some extra space is allocated so the next few times don’t require an actual resize.