• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python rarithmetic.ovfcheck函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pypy.rlib.rarithmetic.ovfcheck函数的典型用法代码示例。如果您正苦于以下问题:Python ovfcheck函数的具体用法?Python ovfcheck怎么用?Python ovfcheck使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ovfcheck函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: ll_join

 def ll_join(s, length, items):
     s_chars = s.chars
     s_len = len(s_chars)
     num_items = length
     if num_items == 0:
         return s.empty()
     itemslen = 0
     i = 0
     while i < num_items:
         try:
             itemslen = ovfcheck(itemslen + len(items[i].chars))
         except OverflowError:
             raise MemoryError
         i += 1
     try:
         seplen = ovfcheck(s_len * (num_items - 1))
     except OverflowError:
         raise MemoryError
     # a single '+' at the end is allowed to overflow: it gets
     # a negative result, and the gc will complain
     result = s.malloc(itemslen + seplen)
     res_index = len(items[0].chars)
     s.copy_contents(items[0], result, 0, 0, res_index)
     i = 1
     while i < num_items:
         s.copy_contents(s, result, 0, res_index, s_len)
         res_index += s_len
         lgt = len(items[i].chars)
         s.copy_contents(items[i], result, 0, res_index, lgt)
         res_index += lgt
         i += 1
     return result
开发者ID:craigkerstiens,项目名称:pypy,代码行数:32,代码来源:rstr.py


示例2: unicode_expandtabs__Unicode_ANY

def unicode_expandtabs__Unicode_ANY(space, w_self, w_tabsize):
    self = w_self._value
    tabsize  = space.int_w(w_tabsize)
    parts = _split_with(self, u'\t')
    result = [parts[0]]
    prevsize = 0
    for ch in parts[0]:
        prevsize += 1
        if ch == u"\n" or ch ==  u"\r":
            prevsize = 0
    totalsize = prevsize

    for i in range(1, len(parts)):
        pad = tabsize - prevsize % tabsize
        nextpart = parts[i]
        try:
            totalsize = ovfcheck(totalsize + pad)
            totalsize = ovfcheck(totalsize + len(nextpart))
            result.append(u' ' * pad)
        except OverflowError:
            raise OperationError(space.w_OverflowError, space.wrap('new string is too long'))
        result.append(nextpart)
        prevsize = 0
        for ch in nextpart:
            prevsize += 1
            if ch in (u"\n", u"\r"):
                prevsize = 0
    return space.wrap(u''.join(result))
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:28,代码来源:unicodeobject.py


示例3: malloc_varsize_clear

 def malloc_varsize_clear(self, typeid16, length, size, itemsize,
                          offset_to_length, can_collect):
     if can_collect:
         self.maybe_collect()
     size_gc_header = self.gcheaderbuilder.size_gc_header
     try:
         fixsize = size_gc_header + size
         varsize = ovfcheck(itemsize * length)
         tot_size = ovfcheck(fixsize + varsize)
         usage = raw_malloc_usage(tot_size)
         bytes_malloced = ovfcheck(self.bytes_malloced+usage)
         ovfcheck(self.heap_usage + bytes_malloced)
     except OverflowError:
         raise memoryError
     result = raw_malloc(tot_size)
     if not result:
         raise memoryError
     raw_memclear(result, tot_size)        
     (result + size_gc_header + offset_to_length).signed[0] = length
     hdr = llmemory.cast_adr_to_ptr(result, self.HDRPTR)
     hdr.typeid16 = typeid16
     hdr.mark = False
     hdr.flags = '\x00'
     hdr.next = self.malloced_objects
     self.malloced_objects = hdr
     self.bytes_malloced = bytes_malloced
         
     result += size_gc_header
     #llop.debug_print(lltype.Void, 'malloc_varsize length', length,
     #                 'typeid', typeid16,
     #                 '->', llmemory.cast_adr_to_int(result))
     self.write_malloc_statistics(typeid16, tot_size, result, True)
     return llmemory.cast_adr_to_ptr(result, llmemory.GCREF)
开发者ID:alkorzt,项目名称:pypy,代码行数:33,代码来源:marksweep.py


示例4: malloc_fixedsize

 def malloc_fixedsize(self, typeid16, size, can_collect,
                      has_finalizer=False, contains_weakptr=False):
     if can_collect:
         self.maybe_collect()
     size_gc_header = self.gcheaderbuilder.size_gc_header
     try:
         tot_size = size_gc_header + size
         usage = raw_malloc_usage(tot_size)
         bytes_malloced = ovfcheck(self.bytes_malloced+usage)
         ovfcheck(self.heap_usage + bytes_malloced)
     except OverflowError:
         raise memoryError
     result = raw_malloc(tot_size)
     if not result:
         raise memoryError
     hdr = llmemory.cast_adr_to_ptr(result, self.HDRPTR)
     hdr.typeid16 = typeid16
     hdr.mark = False
     hdr.flags = '\x00'
     if has_finalizer:
         hdr.next = self.malloced_objects_with_finalizer
         self.malloced_objects_with_finalizer = hdr
     elif contains_weakptr:
         hdr.next = self.objects_with_weak_pointers
         self.objects_with_weak_pointers = hdr
     else:
         hdr.next = self.malloced_objects
         self.malloced_objects = hdr
     self.bytes_malloced = bytes_malloced
     result += size_gc_header
     #llop.debug_print(lltype.Void, 'malloc typeid', typeid16,
     #                 '->', llmemory.cast_adr_to_int(result))
     self.write_malloc_statistics(typeid16, tot_size, result, False)
     return llmemory.cast_adr_to_ptr(result, llmemory.GCREF)
开发者ID:alkorzt,项目名称:pypy,代码行数:34,代码来源:marksweep.py


示例5: _ll_compute_size

 def _ll_compute_size(length, size, itemsize):
     try:
         varsize = ovfcheck(itemsize * length)
         tot_size = ovfcheck(size + varsize)
     except OverflowError:
         raise MemoryError()
     return tot_size
开发者ID:antoine1fr,项目名称:pygirl,代码行数:7,代码来源:transform.py


示例6: handle_new_array

 def handle_new_array(self, arraydescr, op):
     v_length = op.getarg(0)
     total_size = -1
     if isinstance(v_length, ConstInt):
         num_elem = v_length.getint()
         self.known_lengths[op.result] = num_elem
         try:
             var_size = ovfcheck(arraydescr.itemsize * num_elem)
             total_size = ovfcheck(arraydescr.basesize + var_size)
         except OverflowError:
             pass    # total_size is still -1
     elif arraydescr.itemsize == 0:
         total_size = arraydescr.basesize
     if (total_size >= 0 and
             self.gen_malloc_nursery(total_size, op.result)):
         self.gen_initialize_tid(op.result, arraydescr.tid)
         self.gen_initialize_len(op.result, v_length, arraydescr.lendescr)
     elif self.gc_ll_descr.kind == 'boehm':
         self.gen_boehm_malloc_array(arraydescr, v_length, op.result)
     else:
         opnum = op.getopnum()
         if opnum == rop.NEW_ARRAY:
             self.gen_malloc_array(arraydescr, v_length, op.result)
         elif opnum == rop.NEWSTR:
             self.gen_malloc_str(v_length, op.result)
         elif opnum == rop.NEWUNICODE:
             self.gen_malloc_unicode(v_length, op.result)
         else:
             raise NotImplementedError(op.getopname())
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:29,代码来源:rewrite.py


示例7: realloc

 def realloc(self, ptr, newlength, fixedsize, itemsize, lengthofs, grow):
     size_gc_header = self.size_gc_header()
     addr = llmemory.cast_ptr_to_adr(ptr)
     tid = self.get_type_id(addr)
     nonvarsize = size_gc_header + fixedsize
     try:
         varsize = ovfcheck(itemsize * newlength)
         tot_size = ovfcheck(nonvarsize + varsize)
     except OverflowError:
         raise MemoryError()
     oldlength = (addr + lengthofs).signed[0]
     old_tot_size = size_gc_header + fixedsize + oldlength * itemsize
     source_addr = addr - size_gc_header
     self.gen2_resizable_objects.remove(addr)
     if grow:
         result = llop.raw_realloc_grow(llmemory.Address, source_addr,
                                        old_tot_size, tot_size)
     else:
         result = llop.raw_realloc_shrink(llmemory.Address, source_addr,
                                          old_tot_size, tot_size)
     if not result:
         self.gen2_resizable_objects.append(addr)
         raise MemoryError()
     if grow:
         self.gen2_resizable_objects.append(result + size_gc_header)
     else:
         self.gen2_rawmalloced_objects.append(result + size_gc_header)
     self._check_rawsize_alloced(raw_malloc_usage(tot_size) -
                                 raw_malloc_usage(old_tot_size),
                                 can_collect = not grow)
     (result + size_gc_header + lengthofs).signed[0] = newlength
     return llmemory.cast_adr_to_ptr(result + size_gc_header, llmemory.GCREF)
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:32,代码来源:hybrid.py


示例8: malloc_varsize_slowpath

 def malloc_varsize_slowpath(self, typeid, length, force_nonmovable=False):
     # For objects that are too large, or when the nursery is exhausted.
     # In order to keep malloc_varsize_clear() as compact as possible,
     # we recompute what we need in this slow path instead of passing
     # it all as function arguments.
     size_gc_header = self.gcheaderbuilder.size_gc_header
     nonvarsize = size_gc_header + self.fixed_size(typeid)
     itemsize = self.varsize_item_sizes(typeid)
     offset_to_length = self.varsize_offset_to_length(typeid)
     try:
         varsize = ovfcheck(itemsize * length)
         totalsize = ovfcheck(nonvarsize + varsize)
     except OverflowError:
         raise MemoryError()
     if self.has_gcptr_in_varsize(typeid):
         nonlarge_max = self.nonlarge_gcptrs_max
     else:
         nonlarge_max = self.nonlarge_max
     if force_nonmovable or raw_malloc_usage(totalsize) > nonlarge_max:
         result = self.malloc_varsize_marknsweep(totalsize)
         flags = self.GCFLAGS_FOR_NEW_EXTERNAL_OBJECTS | GCFLAG_UNVISITED
     else:
         result = self.malloc_varsize_collecting_nursery(totalsize)
         flags = self.GCFLAGS_FOR_NEW_YOUNG_OBJECTS
     self.init_gc_object(result, typeid, flags)
     (result + size_gc_header + offset_to_length).signed[0] = length
     return llmemory.cast_adr_to_ptr(result+size_gc_header, llmemory.GCREF)
开发者ID:ieure,项目名称:pypy,代码行数:27,代码来源:hybrid.py


示例9: can_inline_malloc_varsize

 def can_inline_malloc_varsize(self, arraydescr, num_elem):
     assert isinstance(arraydescr, BaseArrayDescr)
     basesize = arraydescr.get_base_size(self.translate_support_code)
     itemsize = arraydescr.get_item_size(self.translate_support_code)
     try:
         size = ovfcheck(basesize + ovfcheck(itemsize * num_elem))
         return size < self.max_size_of_young_obj
     except OverflowError:
         return False
开发者ID:craigkerstiens,项目名称:pypy,代码行数:9,代码来源:gc.py


示例10: malloc_array

 def malloc_array(basesize, itemsize, ofs_length, num_elem):
     try:
         size = ovfcheck(basesize + ovfcheck(itemsize * num_elem))
     except OverflowError:
         return lltype.nullptr(llmemory.GCREF.TO)
     res = self.funcptr_for_new(size)
     if not res:
         return res
     rffi.cast(rffi.CArrayPtr(lltype.Signed), res)[ofs_length/WORD] = num_elem
     return res
开发者ID:craigkerstiens,项目名称:pypy,代码行数:10,代码来源:gc.py


示例11: malloc_array

 def malloc_array(basesize, num_elem, itemsize, ofs_length):
     try:
         totalsize = ovfcheck(basesize + ovfcheck(itemsize * num_elem))
     except OverflowError:
         return lltype.nullptr(llmemory.GCREF.TO)
     res = self.malloc_fn_ptr(totalsize)
     if res:
         arrayptr = rffi.cast(rffi.CArrayPtr(lltype.Signed), res)
         arrayptr[ofs_length/WORD] = num_elem
     return res
开发者ID:ParitoshThapliyal59,项目名称:pypy,代码行数:10,代码来源:gc.py


示例12: f

 def f(x):
     try:
         a = ovfcheck(x + 50)
     except OverflowError:
         return 0
     try:
         a += ovfcheck(100 + x)
     except OverflowError:
         return 1
     return a
开发者ID:ieure,项目名称:pypy,代码行数:10,代码来源:test_rint.py


示例13: ll_malloc_varsize_no_length

 def ll_malloc_varsize_no_length(length, size, itemsize):
     try:
         varsize = ovfcheck(itemsize * length)
         tot_size = ovfcheck(size + varsize)
     except OverflowError:
         raise memoryError
     result = llop.boehm_malloc(llmemory.Address, tot_size)
     if not result:
         raise memoryError
     return result
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:10,代码来源:boehm.py


示例14: ll_malloc_varsize_no_length

 def ll_malloc_varsize_no_length(length, size, itemsize):
     try:
         fixsize = gc_header_offset + size
         varsize = ovfcheck(itemsize * length)
         tot_size = ovfcheck(fixsize + varsize)
     except OverflowError:
         raise MemoryError()
     result = mh._ll_malloc_fixedsize(tot_size)
     llmemory.raw_memclear(result, tot_size)
     result += gc_header_offset
     return result
开发者ID:alkorzt,项目名称:pypy,代码行数:11,代码来源:refcounting.py


示例15: add

 def add(self, offset):
     res = self.clone()
     try:
         res.lower = ovfcheck(res.lower + offset)
     except OverflowError:
         res.has_lower = False
     try:
         res.upper = ovfcheck(res.upper + offset)
     except OverflowError:
         res.has_upper = False
     return res
开发者ID:gorakhargosh,项目名称:pypy,代码行数:11,代码来源:intutils.py


示例16: fn

 def fn(x, y):
     res = -42
     try:
         res = ovfcheck(x+y)
     except OverflowError:
         res = 0
     try:
         res += ovfcheck(x+y)
     except OverflowError:
         res += 1
     return res
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:11,代码来源:operations.py


示例17: f

 def f(x, y):
     i = 0
     while i < 10:
         myjitdriver.can_enter_jit(x=x, y=y, i=i)
         myjitdriver.jit_merge_point(x=x, y=y, i=i)
         try:
             ovfcheck(i%x)
             i += 1
         except ZeroDivisionError:
             i += 1
         except OverflowError:
             i += 2
     return 0
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:13,代码来源:test_exception.py


示例18: mul_bound

 def mul_bound(self, other):
     if self.has_upper and self.has_lower and \
        other.has_upper and other.has_lower:
         try:
             vals = (ovfcheck(self.upper * other.upper),
                     ovfcheck(self.upper * other.lower),
                     ovfcheck(self.lower * other.upper),
                     ovfcheck(self.lower * other.lower))
             return IntBound(min4(vals), max4(vals))
         except OverflowError:
             return IntUnbounded()
     else:
         return IntUnbounded()
开发者ID:gorakhargosh,项目名称:pypy,代码行数:13,代码来源:intutils.py


示例19: ll_malloc_varsize_no_length

 def ll_malloc_varsize_no_length(length, size, itemsize):
     try:
         fixsize = gc_header_offset + size
         varsize = ovfcheck(itemsize * length)
         tot_size = ovfcheck(fixsize + varsize)
     except OverflowError:
         raise memoryError
     result = lladdress.raw_malloc(tot_size)
     if not result:
         raise memoryError
     lladdress.raw_memclear(result, tot_size)
     result += gc_header_offset
     return result
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:13,代码来源:refcounting.py


示例20: div_bound

 def div_bound(self, other):
     if self.has_upper and self.has_lower and \
        other.has_upper and other.has_lower and \
        not other.contains(0):
         try:
             vals = (ovfcheck(self.upper / other.upper),
                     ovfcheck(self.upper / other.lower),
                     ovfcheck(self.lower / other.upper),
                     ovfcheck(self.lower / other.lower))
             return IntBound(min4(vals), max4(vals))
         except OverflowError:
             return IntUnbounded()
     else:
         return IntUnbounded()
开发者ID:gorakhargosh,项目名称:pypy,代码行数:14,代码来源:intutils.py



注:本文中的pypy.rlib.rarithmetic.ovfcheck函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python rarithmetic.r_longlong函数代码示例发布时间:2022-05-27
下一篇:
Python rarithmetic.intmask函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap