def make_implementation(space, list_w):
    if not list_w:
        return space.fromcache(State).empty_impl
    if space.config.objspace.std.withsmartresizablelist:
        from pypy.objspace.std.smartresizablelist import \
            SmartResizableListImplementation
        impl = SmartResizableListImplementation(space)
        impl.extend(RListImplementation(space, list_w))
        return impl
    if space.config.objspace.std.withchunklist:
        return ChunkedListImplementation(space, list_w)
    if space.config.objspace.std.withblist:
        from pypy.objspace.std.blistimplementation import BListImplementation
        return BListImplementation(space, list_w)
    elif space.config.objspace.std.withfastslice:
        return SliceTrackingListImplementation(space, list_w)
    else:
        # check if it's strings only
        w_type = space.type(list_w[0])
        if (space.is_w(w_type, space.w_str) and
            is_homogeneous(space, list_w, w_type)):
            strlist = [space.str_w(w_i) for w_i in list_w]
            return StrListImplementation(space, strlist)
        else:
            return RListImplementation(space, list_w)
def make_implementation_with_one_item(space, w_item):
    if space.config.objspace.std.withfastslice:
        return SliceTrackingListImplementation(space, [w_item])
    if space.config.objspace.std.withsmartresizablelist:
        from pypy.objspace.std.smartresizablelist import \
            SmartResizableListImplementation
        impl = SmartResizableListImplementation(space)
        impl.append(w_item)
        return impl
    if space.config.objspace.std.withchunklist:
        return ChunkedListImplementation(space, [w_item])
    if space.config.objspace.std.withblist:
        from pypy.objspace.std.blistimplementation import BListImplementation
        return BListImplementation(space, [w_item])
    w_type = space.type(w_item)
    if space.is_w(w_type, space.w_str):
        strlist = [space.str_w(w_item)]
        return StrListImplementation(space, strlist)
    return RListImplementation(space, [w_item])